Asterisk-Java

org.asteriskjava.fastagi
Class AgiOperations

java.lang.Object
  extended by org.asteriskjava.fastagi.AgiOperations
All Implemented Interfaces:
AgiChannel
Direct Known Subclasses:
BaseAgiScript

public class AgiOperations
extends java.lang.Object
implements AgiChannel

AgiOperations provides some convinience methods that wrap the various AgiCommands.

Since:
0.3
Version:
$Id: AgiOperations.java 1271 2009-03-21 03:41:24Z srt $
Author:
srt

Constructor Summary
AgiOperations()
          Creates a new instance that operates on the channel attached to the current thread.
AgiOperations(AgiChannel channel)
          Creates a new instance that operates on the given channel.
 
Method Summary
 void answer()
          Answers the channel.
 void continueAt(java.lang.String context, java.lang.String extension, java.lang.String priority)
          Defines the point in the dialplan where the call will continue when the AGI script returns.
 void controlStreamFile(java.lang.String file)
          Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind.
 char controlStreamFile(java.lang.String file, java.lang.String escapeDigits)
          Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind.
 char controlStreamFile(java.lang.String file, java.lang.String escapeDigits, int offset)
          Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind.
 char controlStreamFile(java.lang.String file, java.lang.String escapeDigits, int offset, java.lang.String forwardDigit, java.lang.String rewindDigit, java.lang.String pauseDigit)
          Plays the given file allowing the user to control the streaming by using forwardDigit for forward, rewindDigit for rewind and pauseDigit for pause.
 void databaseDel(java.lang.String family, java.lang.String key)
          Deletes an entry in the Asterisk database for a given family and key.
 void databaseDelTree(java.lang.String family)
          Deletes a whole family of entries in the Asterisk database.
 void databaseDelTree(java.lang.String family, java.lang.String keytree)
          Deletes all entries of a given family in the Asterisk database that have a key that starts with a given prefix.
 java.lang.String databaseGet(java.lang.String family, java.lang.String key)
          Retrieves an entry in the Asterisk database for a given family and key.
 void databasePut(java.lang.String family, java.lang.String key, java.lang.String value)
          Adds or updates an entry in the Asterisk database for a given family, key, and value.
 int exec(java.lang.String application)
          Executes the given command.
 int exec(java.lang.String application, java.lang.String options)
          Executes the given command.
protected  AgiChannel getChannel()
          Returns the channel to operate on.
 int getChannelStatus()
          Returns the status of the channel.
 java.lang.String getData(java.lang.String file)
          Plays the given file and waits for the user to enter DTMF digits until he presses '#'.
 java.lang.String getData(java.lang.String file, long timeout)
          Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs.
 java.lang.String getData(java.lang.String file, long timeout, int maxDigits)
          Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs or the maximum number of digits has been entered.
 java.lang.String getFullVariable(java.lang.String name)
          Evaluates a channel expression for the current channel.
 java.lang.String getFullVariable(java.lang.String name, java.lang.String channel)
          Evaluates a channel expression for the given channel.To extract the caller id of channel use getFullVariable("${CALLERID(name)}", "SIP/john-0085d860");.
 AgiReply getLastReply()
          Returns the reply received in response to the last command sent to Asterisk.
 java.lang.String getName()
          Returns the name of the channel.
 char getOption(java.lang.String file, java.lang.String escapeDigits)
          Plays the given file, and waits for the user to press one of the given digits.
 char getOption(java.lang.String file, java.lang.String escapeDigits, long timeout)
          Plays the given file, and waits for the user to press one of the given digits.
 java.lang.String getUniqueId()
          Returns the unqiue id of the channel.
 java.lang.String getVariable(java.lang.String name)
          Returns the value of the current channel or global variable.
 void hangup()
          Hangs the channel up.
 void playMusicOnHold()
          Plays music on hold from the default music on hold class.
 void playMusicOnHold(java.lang.String musicOnHoldClass)
          Plays music on hold from the given music on hold class.
 char recordFile(java.lang.String file, java.lang.String format, java.lang.String escapeDigits, int timeout)
          Record to a file until a given dtmf digit in the sequence is received.
 char recordFile(java.lang.String file, java.lang.String format, java.lang.String escapeDigits, int timeout, int offset, boolean beep, int maxSilence)
          Record to a file until a given dtmf digit in the sequence is received.
 void sayAlpha(java.lang.String text)
          Says the given character string.
 char sayAlpha(java.lang.String text, java.lang.String escapeDigits)
          Says the given character string, returning early if any of the given DTMF number are received on the channel.
 void sayDateTime(long time)
          Says the given time.
 char sayDateTime(long time, java.lang.String escapeDigits)
          Says the given time and allows interruption by one of the given escape digits.
 char sayDateTime(long time, java.lang.String escapeDigits, java.lang.String format)
          Says the given time in the given format and allows interruption by one of the given escape digits.
 char sayDateTime(long time, java.lang.String escapeDigits, java.lang.String format, java.lang.String timezone)
          Says the given time in the given format and timezone and allows interruption by one of the given escape digits.
 void sayDigits(java.lang.String digits)
          Says the given digit string.
 char sayDigits(java.lang.String digits, java.lang.String escapeDigits)
          Says the given number, returning early if any of the given DTMF number are received on the channel.
 void sayNumber(java.lang.String number)
          Says the given number.
 char sayNumber(java.lang.String number, java.lang.String escapeDigits)
          Says the given number, returning early if any of the given DTMF number are received on the channel.
 void sayPhonetic(java.lang.String text)
          Says the given character string with phonetics.
 char sayPhonetic(java.lang.String text, java.lang.String escapeDigits)
          Says the given character string with phonetics, returning early if any of the given DTMF number are received on the channel.
 void sayTime(long time)
          Says the given time.
 char sayTime(long time, java.lang.String escapeDigits)
          Says the given time, returning early if any of the given DTMF number are received on the channel.
 AgiReply sendCommand(AgiCommand command)
          Sends a command to asterisk and returns the corresponding reply.
 void setAutoHangup(int time)
          Cause the channel to automatically hangup at the given number of seconds in the future.
 void setCallerId(java.lang.String callerId)
          Sets the caller id on the current channel.
 void setContext(java.lang.String context)
          Sets the context for continuation upon exiting the application.
 void setExtension(java.lang.String extension)
          Sets the extension for continuation upon exiting the application.
 void setPriority(java.lang.String priority)
          Sets the priority or label for continuation upon exiting the application.
 void setVariable(java.lang.String name, java.lang.String value)
          Sets the value of the current channel or global variable to a new value.
 void speechActivateGrammar(java.lang.String name)
          Activates the specified grammar.
 void speechCreate()
          Creates a speech object that uses the default speech engine.
 void speechCreate(java.lang.String engine)
          Creates a speech object that uses the given speech engine.
 void speechDeactivateGrammar(java.lang.String name)
          Deactivates the specified grammar.
 void speechDestroy()
          Destroys the current speech object.
 void speechLoadGrammar(java.lang.String name, java.lang.String path)
          Loads the specified grammar.
 SpeechRecognitionResult speechRecognize(java.lang.String prompt, int timeout)
          Plays the given prompt while listening for speech and DTMF.
 SpeechRecognitionResult speechRecognize(java.lang.String prompt, int timeout, int offset)
          Plays the given prompt while listening for speech and DTMF.
 void speechSet(java.lang.String name, java.lang.String value)
          Sets the speech engine setting indicated by name to the given value.
 void speechUnloadGrammar(java.lang.String name)
          Unloads the specified grammar.
 void stopMusicOnHold()
          Stops playing music on hold.
 void streamFile(java.lang.String file)
          Plays the given file.
 char streamFile(java.lang.String file, java.lang.String escapeDigits)
          Plays the given file and allows the user to escape by pressing one of the given digit.
 char streamFile(java.lang.String file, java.lang.String escapeDigits, int offset)
          Plays the given file starting at the specified offset and allows the user to escape by pressing one of the given digit.
 void verbose(java.lang.String message, int level)
          Sends a message to the Asterisk console via the verbose message system.
 char waitForDigit(int timeout)
          Waits up to 'timeout' milliseconds to receive a DTMF digit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgiOperations

public AgiOperations()
Creates a new instance that operates on the channel attached to the current thread.


AgiOperations

public AgiOperations(AgiChannel channel)
Creates a new instance that operates on the given channel.

Parameters:
channel - the channel to operate on.
Method Detail

getChannel

protected AgiChannel getChannel()
Returns the channel to operate on.

Returns:
the channel to operate on.
Throws:
java.lang.IllegalStateException - if no AgiChannel is bound to the current channel and no channel has been passed to the constructor.

getName

public java.lang.String getName()
Description copied from interface: AgiChannel
Returns the name of the channel.

Specified by:
getName in interface AgiChannel
Returns:
the name of the channel.

getUniqueId

public java.lang.String getUniqueId()
Description copied from interface: AgiChannel
Returns the unqiue id of the channel.

Specified by:
getUniqueId in interface AgiChannel
Returns:
the unqiue id of the channel.

getLastReply

public AgiReply getLastReply()
Description copied from interface: AgiChannel
Returns the reply received in response to the last command sent to Asterisk.

Specified by:
getLastReply in interface AgiChannel
Returns:
the reply received in response to the last command sent to Asterisk or null if none has yet been received.

sendCommand

public AgiReply sendCommand(AgiCommand command)
                     throws AgiException
Description copied from interface: AgiChannel
Sends a command to asterisk and returns the corresponding reply. The reply is also available through AgiChannel.getLastReply().

Specified by:
sendCommand in interface AgiChannel
Parameters:
command - the command to send.
Returns:
the reply of the asterisk server containing the return value.
Throws:
AgiException - if the command can't be sent to Asterisk (for example because the channel has been hung up)

answer

public void answer()
            throws AgiException
Description copied from interface: AgiChannel
Answers the channel.

Specified by:
answer in interface AgiChannel
Throws:
AgiException

hangup

public void hangup()
            throws AgiException
Description copied from interface: AgiChannel
Hangs the channel up.

Specified by:
hangup in interface AgiChannel
Throws:
AgiException

setAutoHangup

public void setAutoHangup(int time)
                   throws AgiException
Description copied from interface: AgiChannel
Cause the channel to automatically hangup at the given number of seconds in the future.

Specified by:
setAutoHangup in interface AgiChannel
Parameters:
time - the number of seconds before this channel is automatically hung up.

0 disables the autohangup feature.

Throws:
AgiException

setCallerId

public void setCallerId(java.lang.String callerId)
                 throws AgiException
Description copied from interface: AgiChannel
Sets the caller id on the current channel.

Specified by:
setCallerId in interface AgiChannel
Parameters:
callerId - the raw caller id to set, for example "John Doe<1234>".
Throws:
AgiException

playMusicOnHold

public void playMusicOnHold()
                     throws AgiException
Description copied from interface: AgiChannel
Plays music on hold from the default music on hold class.

Specified by:
playMusicOnHold in interface AgiChannel
Throws:
AgiException

playMusicOnHold

public void playMusicOnHold(java.lang.String musicOnHoldClass)
                     throws AgiException
Description copied from interface: AgiChannel
Plays music on hold from the given music on hold class.

Specified by:
playMusicOnHold in interface AgiChannel
Parameters:
musicOnHoldClass - the music on hold class to play music from as configures in Asterisk's .
Throws:
AgiException

stopMusicOnHold

public void stopMusicOnHold()
                     throws AgiException
Description copied from interface: AgiChannel
Stops playing music on hold.

Specified by:
stopMusicOnHold in interface AgiChannel
Throws:
AgiException

getChannelStatus

public int getChannelStatus()
                     throws AgiException
Description copied from interface: AgiChannel
Returns the status of the channel.

Return values:

  • 0 Channel is down and available
  • 1 Channel is down, but reserved
  • 2 Channel is off hook
  • 3 Digits (or equivalent) have been dialed
  • 4 Line is ringing
  • 5 Remote end is ringing
  • 6 Line is up
  • 7 Line is busy

Specified by:
getChannelStatus in interface AgiChannel
Returns:
the status of the channel.
Throws:
AgiException

getData

public java.lang.String getData(java.lang.String file)
                         throws AgiException
Description copied from interface: AgiChannel
Plays the given file and waits for the user to enter DTMF digits until he presses '#'. The user may interrupt the streaming by starting to enter digits.

Specified by:
getData in interface AgiChannel
Parameters:
file - the name of the file to play
Returns:
a String containing the DTMF the user entered
Throws:
AgiException

getData

public java.lang.String getData(java.lang.String file,
                                long timeout)
                         throws AgiException
Description copied from interface: AgiChannel
Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs. The user may interrupt the streaming by starting to enter digits.

Specified by:
getData in interface AgiChannel
Parameters:
file - the name of the file to play
timeout - the timeout in milliseconds to wait for user input.

0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).

Returns:
a String containing the DTMF the user entered
Throws:
AgiException

getData

public java.lang.String getData(java.lang.String file,
                                long timeout,
                                int maxDigits)
                         throws AgiException
Description copied from interface: AgiChannel
Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs or the maximum number of digits has been entered. The user may interrupt the streaming by starting to enter digits.

Specified by:
getData in interface AgiChannel
Parameters:
file - the name of the file to play
timeout - the timeout in milliseconds to wait for user input.

0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).

maxDigits - the maximum number of digits the user is allowed to enter
Returns:
a String containing the DTMF the user entered
Throws:
AgiException

getOption

public char getOption(java.lang.String file,
                      java.lang.String escapeDigits)
               throws AgiException
Description copied from interface: AgiChannel
Plays the given file, and waits for the user to press one of the given digits. If none of the esacpe digits is pressed while streaming the file it waits for the default timeout of 5 seconds still waiting for the user to press a digit.

Specified by:
getOption in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that the user is expected to press.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

getOption

public char getOption(java.lang.String file,
                      java.lang.String escapeDigits,
                      long timeout)
               throws AgiException
Description copied from interface: AgiChannel
Plays the given file, and waits for the user to press one of the given digits. If none of the esacpe digits is pressed while streaming the file it waits for the specified timeout still waiting for the user to press a digit.

Specified by:
getOption in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that the user is expected to press.
timeout - the timeout in milliseconds to wait if none of the defined esacpe digits was presses while streaming.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

exec

public int exec(java.lang.String application)
         throws AgiException
Description copied from interface: AgiChannel
Executes the given command.

Specified by:
exec in interface AgiChannel
Parameters:
application - the name of the application to execute, for example "Dial".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AgiException

exec

public int exec(java.lang.String application,
                java.lang.String options)
         throws AgiException
Description copied from interface: AgiChannel
Executes the given command.

Specified by:
exec in interface AgiChannel
Parameters:
application - the name of the application to execute, for example "Dial".
options - the parameters to pass to the application, for example "SIP/123".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AgiException

setContext

public void setContext(java.lang.String context)
                throws AgiException
Description copied from interface: AgiChannel
Sets the context for continuation upon exiting the application.

Specified by:
setContext in interface AgiChannel
Parameters:
context - the context for continuation upon exiting the application.
Throws:
AgiException

setExtension

public void setExtension(java.lang.String extension)
                  throws AgiException
Description copied from interface: AgiChannel
Sets the extension for continuation upon exiting the application.

Specified by:
setExtension in interface AgiChannel
Parameters:
extension - the extension for continuation upon exiting the application.
Throws:
AgiException

setPriority

public void setPriority(java.lang.String priority)
                 throws AgiException
Description copied from interface: AgiChannel
Sets the priority or label for continuation upon exiting the application.

Specified by:
setPriority in interface AgiChannel
Parameters:
priority - the priority or label for continuation upon exiting the application.
Throws:
AgiException

streamFile

public void streamFile(java.lang.String file)
                throws AgiException
Description copied from interface: AgiChannel
Plays the given file.

Specified by:
streamFile in interface AgiChannel
Parameters:
file - name of the file to play.
Throws:
AgiException

streamFile

public char streamFile(java.lang.String file,
                       java.lang.String escapeDigits)
                throws AgiException
Description copied from interface: AgiChannel
Plays the given file and allows the user to escape by pressing one of the given digit.

Specified by:
streamFile in interface AgiChannel
Parameters:
file - name of the file to play.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

streamFile

public char streamFile(java.lang.String file,
                       java.lang.String escapeDigits,
                       int offset)
                throws AgiException
Description copied from interface: AgiChannel
Plays the given file starting at the specified offset and allows the user to escape by pressing one of the given digit.

Specified by:
streamFile in interface AgiChannel
Parameters:
file - name of the file to play.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
offset - the offset samples to skip before streaming.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayDigits

public void sayDigits(java.lang.String digits)
               throws AgiException
Description copied from interface: AgiChannel
Says the given digit string.

Specified by:
sayDigits in interface AgiChannel
Parameters:
digits - the digit string to say.
Throws:
AgiException

sayDigits

public char sayDigits(java.lang.String digits,
                      java.lang.String escapeDigits)
               throws AgiException
Description copied from interface: AgiChannel
Says the given number, returning early if any of the given DTMF number are received on the channel.

Specified by:
sayDigits in interface AgiChannel
Parameters:
digits - the digit string to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayNumber

public void sayNumber(java.lang.String number)
               throws AgiException
Description copied from interface: AgiChannel
Says the given number.

Specified by:
sayNumber in interface AgiChannel
Parameters:
number - the number to say.
Throws:
AgiException

sayNumber

public char sayNumber(java.lang.String number,
                      java.lang.String escapeDigits)
               throws AgiException
Description copied from interface: AgiChannel
Says the given number, returning early if any of the given DTMF number are received on the channel.

Specified by:
sayNumber in interface AgiChannel
Parameters:
number - the number to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayPhonetic

public void sayPhonetic(java.lang.String text)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given character string with phonetics.

Specified by:
sayPhonetic in interface AgiChannel
Parameters:
text - the text to say.
Throws:
AgiException

sayPhonetic

public char sayPhonetic(java.lang.String text,
                        java.lang.String escapeDigits)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given character string with phonetics, returning early if any of the given DTMF number are received on the channel.

Specified by:
sayPhonetic in interface AgiChannel
Parameters:
text - the text to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayAlpha

public void sayAlpha(java.lang.String text)
              throws AgiException
Description copied from interface: AgiChannel
Says the given character string.

Specified by:
sayAlpha in interface AgiChannel
Parameters:
text - the text to say.
Throws:
AgiException

sayAlpha

public char sayAlpha(java.lang.String text,
                     java.lang.String escapeDigits)
              throws AgiException
Description copied from interface: AgiChannel
Says the given character string, returning early if any of the given DTMF number are received on the channel.

Specified by:
sayAlpha in interface AgiChannel
Parameters:
text - the text to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayTime

public void sayTime(long time)
             throws AgiException
Description copied from interface: AgiChannel
Says the given time.

Specified by:
sayTime in interface AgiChannel
Parameters:
time - the time to say in seconds since 00:00:00 on January 1, 1970.
Throws:
AgiException

sayTime

public char sayTime(long time,
                    java.lang.String escapeDigits)
             throws AgiException
Description copied from interface: AgiChannel
Says the given time, returning early if any of the given DTMF number are received on the channel.

Specified by:
sayTime in interface AgiChannel
Parameters:
time - the time to say in seconds since 00:00:00 on January 1, 1970.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

getVariable

public java.lang.String getVariable(java.lang.String name)
                             throws AgiException
Description copied from interface: AgiChannel
Returns the value of the current channel or global variable.

Supports functions and builtin variables. To retrieve the caller id you can use getVariable("CALLERID(name)");

Does not support expression parsing, use AgiChannel.getFullVariable(String) in those cases.

Specified by:
getVariable in interface AgiChannel
Parameters:
name - the name of the variable (or function call) to retrieve.
Returns:
the value of the given variable or null if not set.
Throws:
AgiException

setVariable

public void setVariable(java.lang.String name,
                        java.lang.String value)
                 throws AgiException
Description copied from interface: AgiChannel
Sets the value of the current channel or global variable to a new value.

Supports functions and builtin variables. To set the caller id you can use setVariable("CALLERID(name)", "John Doe");

Specified by:
setVariable in interface AgiChannel
Parameters:
name - the name of the variable (or function call) to set.
value - the new value to set.
Throws:
AgiException

waitForDigit

public char waitForDigit(int timeout)
                  throws AgiException
Description copied from interface: AgiChannel
Waits up to 'timeout' milliseconds to receive a DTMF digit.

Specified by:
waitForDigit in interface AgiChannel
Parameters:
timeout - timeout the milliseconds to wait for the channel to receive a DTMF digit, -1 will wait forever.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

getFullVariable

public java.lang.String getFullVariable(java.lang.String name)
                                 throws AgiException
Description copied from interface: AgiChannel
Evaluates a channel expression for the current channel. To extract the caller id use getFullVariable("${CALLERID(name)}");.

Available since Asterisk 1.2.

Specified by:
getFullVariable in interface AgiChannel
Parameters:
name - the expression to evaluate.
Returns:
the value of the given expression or null if not set.
Throws:
AgiException
See Also:
AgiChannel.getVariable(String)

getFullVariable

public java.lang.String getFullVariable(java.lang.String name,
                                        java.lang.String channel)
                                 throws AgiException
Description copied from interface: AgiChannel
Evaluates a channel expression for the given channel.To extract the caller id of channel use getFullVariable("${CALLERID(name)}", "SIP/john-0085d860");.

Available since Asterisk 1.2.

Specified by:
getFullVariable in interface AgiChannel
Parameters:
name - the the expression to evaluate.
channel - the name of the channel.
Returns:
the value of the given expression or null if not set.
Throws:
AgiException

sayDateTime

public void sayDateTime(long time)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given time.

Available since Asterisk 1.2.

Specified by:
sayDateTime in interface AgiChannel
Parameters:
time - the time to say in seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)
Throws:
AgiException

sayDateTime

public char sayDateTime(long time,
                        java.lang.String escapeDigits)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given time and allows interruption by one of the given escape digits.

Available since Asterisk 1.2.

Specified by:
sayDateTime in interface AgiChannel
Parameters:
time - the time to say in seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)
escapeDigits - the digits that allow the user to interrupt this command or null for none.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayDateTime

public char sayDateTime(long time,
                        java.lang.String escapeDigits,
                        java.lang.String format)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given time in the given format and allows interruption by one of the given escape digits.

Available since Asterisk 1.2.

Specified by:
sayDateTime in interface AgiChannel
Parameters:
time - the time to say in seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)
escapeDigits - the digits that allow the user to interrupt this command or null for none.
format - the format the time should be said in
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

sayDateTime

public char sayDateTime(long time,
                        java.lang.String escapeDigits,
                        java.lang.String format,
                        java.lang.String timezone)
                 throws AgiException
Description copied from interface: AgiChannel
Says the given time in the given format and timezone and allows interruption by one of the given escape digits.

Available since Asterisk 1.2.

Specified by:
sayDateTime in interface AgiChannel
Parameters:
time - the time to say in seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)
escapeDigits - the digits that allow the user to interrupt this command or null for none.
format - the format the time should be said in
timezone - the timezone to use when saying the time, for example "UTC" or "Europe/Berlin".
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

databaseGet

public java.lang.String databaseGet(java.lang.String family,
                                    java.lang.String key)
                             throws AgiException
Description copied from interface: AgiChannel
Retrieves an entry in the Asterisk database for a given family and key.

Specified by:
databaseGet in interface AgiChannel
Parameters:
family - the family of the entry to retrieve.
key - the key of the entry to retrieve.
Returns:
the value of the given family and key or null if there is no such value.
Throws:
AgiException

databasePut

public void databasePut(java.lang.String family,
                        java.lang.String key,
                        java.lang.String value)
                 throws AgiException
Description copied from interface: AgiChannel
Adds or updates an entry in the Asterisk database for a given family, key, and value.

Specified by:
databasePut in interface AgiChannel
Parameters:
family - the family of the entry to add or update.
key - the key of the entry to add or update.
value - the new value of the entry.
Throws:
AgiException

databaseDel

public void databaseDel(java.lang.String family,
                        java.lang.String key)
                 throws AgiException
Description copied from interface: AgiChannel
Deletes an entry in the Asterisk database for a given family and key.

Specified by:
databaseDel in interface AgiChannel
Parameters:
family - the family of the entry to delete.
key - the key of the entry to delete.
Throws:
AgiException

databaseDelTree

public void databaseDelTree(java.lang.String family)
                     throws AgiException
Description copied from interface: AgiChannel
Deletes a whole family of entries in the Asterisk database.

Specified by:
databaseDelTree in interface AgiChannel
Parameters:
family - the family to delete.
Throws:
AgiException

databaseDelTree

public void databaseDelTree(java.lang.String family,
                            java.lang.String keytree)
                     throws AgiException
Description copied from interface: AgiChannel
Deletes all entries of a given family in the Asterisk database that have a key that starts with a given prefix.

Specified by:
databaseDelTree in interface AgiChannel
Parameters:
family - the family of the entries to delete.
keytree - the prefix of the keys of the entries to delete.
Throws:
AgiException

verbose

public void verbose(java.lang.String message,
                    int level)
             throws AgiException
Description copied from interface: AgiChannel
Sends a message to the Asterisk console via the verbose message system.

Specified by:
verbose in interface AgiChannel
Parameters:
message - the message to send.
level - the verbosity level to use. Must be in [1..4].
Throws:
AgiException

recordFile

public char recordFile(java.lang.String file,
                       java.lang.String format,
                       java.lang.String escapeDigits,
                       int timeout)
                throws AgiException
Description copied from interface: AgiChannel
Record to a file until a given dtmf digit in the sequence is received.

Specified by:
recordFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
format - the format of the file to be recorded, for example "wav".
escapeDigits - contains the digits that allow the user to end recording.
timeout - the maximum record time in milliseconds, or -1 for no timeout.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

recordFile

public char recordFile(java.lang.String file,
                       java.lang.String format,
                       java.lang.String escapeDigits,
                       int timeout,
                       int offset,
                       boolean beep,
                       int maxSilence)
                throws AgiException
Description copied from interface: AgiChannel
Record to a file until a given dtmf digit in the sequence is received.

Specified by:
recordFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
format - the format of the file to be recorded, for example "wav".
escapeDigits - contains the digits that allow the user to end recording.
timeout - the maximum record time in milliseconds, or -1 for no timeout.
offset - the offset samples to skip.
beep - true if a beep should be played before recording.
maxSilence - The amount of silence (in seconds) to allow before returning despite the lack of dtmf digits or reaching timeout.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

controlStreamFile

public void controlStreamFile(java.lang.String file)
                       throws AgiException
Description copied from interface: AgiChannel
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind.

Specified by:
controlStreamFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
Throws:
AgiException

controlStreamFile

public char controlStreamFile(java.lang.String file,
                              java.lang.String escapeDigits)
                       throws AgiException
Description copied from interface: AgiChannel
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. Pressing one of the escape digits stops streaming.

Specified by:
controlStreamFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that allow the user to interrupt this command.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

controlStreamFile

public char controlStreamFile(java.lang.String file,
                              java.lang.String escapeDigits,
                              int offset)
                       throws AgiException
Description copied from interface: AgiChannel
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. Pressing one of the escape digits stops streaming. The file is played starting at the indicated offset.

Specified by:
controlStreamFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that allow the user to interrupt this command. May be null if you don't want the user to interrupt.
offset - the offset samples to skip before streaming.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

controlStreamFile

public char controlStreamFile(java.lang.String file,
                              java.lang.String escapeDigits,
                              int offset,
                              java.lang.String forwardDigit,
                              java.lang.String rewindDigit,
                              java.lang.String pauseDigit)
                       throws AgiException
Description copied from interface: AgiChannel
Plays the given file allowing the user to control the streaming by using forwardDigit for forward, rewindDigit for rewind and pauseDigit for pause. Pressing one of the escape digits stops streaming. The file is played starting at the indicated offset, use 0 to start at the beginning.

Specified by:
controlStreamFile in interface AgiChannel
Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that allow the user to interrupt this command. May be null if you don't want the user to interrupt.
offset - the offset samples to skip before streaming, use 0 to start at the beginning.
forwardDigit - the digit for fast forward.
rewindDigit - the digit for rewind.
pauseDigit - the digit for pause and unpause.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AgiException

speechCreate

public void speechCreate()
                  throws AgiException
Description copied from interface: AgiChannel
Creates a speech object that uses the default speech engine. The speech object is used by the other speech methods and must be created before they are called.

Specified by:
speechCreate in interface AgiChannel
Throws:
AgiSpeechException - if the speech object cannot be created.
AgiException
See Also:
AgiChannel.speechDestroy()

speechCreate

public void speechCreate(java.lang.String engine)
                  throws AgiException
Description copied from interface: AgiChannel
Creates a speech object that uses the given speech engine. The speech object is used by the other speech methods and must be created before they are called.

Specified by:
speechCreate in interface AgiChannel
Parameters:
engine - the name of the speech engine. For example "lumenvox".
Throws:
AgiSpeechException - if the speech object cannot be created.
AgiException
See Also:
AgiChannel.speechDestroy()

speechSet

public void speechSet(java.lang.String name,
                      java.lang.String value)
               throws AgiException
Description copied from interface: AgiChannel
Sets the speech engine setting indicated by name to the given value.

Specified by:
speechSet in interface AgiChannel
Parameters:
name - the name of the setting to set.
value - the value to set.
Throws:
AgiSpeechException - if the setting cannot be set.
AgiException

speechDestroy

public void speechDestroy()
                   throws AgiException
Description copied from interface: AgiChannel
Destroys the current speech object.

Specified by:
speechDestroy in interface AgiChannel
Throws:
AgiSpeechException - if the speech engine cannot be destroyed.
AgiException
See Also:
AgiChannel.speechCreate(String)

speechLoadGrammar

public void speechLoadGrammar(java.lang.String name,
                              java.lang.String path)
                       throws AgiException
Description copied from interface: AgiChannel
Loads the specified grammar. The grammer is then available for calls to AgiChannel.speechActivateGrammar(String) under the given name. Eplicitly loading a grammer is only required if the grammer has not been defined in the speech engine configuration, e.g. the [grammars] section of lumenvox.conf.

Specified by:
speechLoadGrammar in interface AgiChannel
Parameters:
name - the name of the grammar, used for subsequent calls to AgiChannel.speechActivateGrammar(String), AgiChannel.speechDeactivateGrammar(String) and AgiChannel.speechUnloadGrammar(String).
path - the path to the grammar to load.
Throws:
AgiSpeechException - if the grammar cannot be loaded.
AgiException
See Also:
AgiChannel.speechUnloadGrammar(String), AgiChannel.speechActivateGrammar(String)

speechUnloadGrammar

public void speechUnloadGrammar(java.lang.String name)
                         throws AgiException
Description copied from interface: AgiChannel
Unloads the specified grammar.

Specified by:
speechUnloadGrammar in interface AgiChannel
Parameters:
name - the name of the grammar to unload.
Throws:
AgiSpeechException - if the grammar cannot be unloaded.
AgiException
See Also:
AgiChannel.speechLoadGrammar(String, String)

speechActivateGrammar

public void speechActivateGrammar(java.lang.String name)
                           throws AgiException
Description copied from interface: AgiChannel
Activates the specified grammar.

Specified by:
speechActivateGrammar in interface AgiChannel
Parameters:
name - the name of the grammar to activate.
Throws:
AgiSpeechException - if the grammar cannot be activated.
AgiException
See Also:
AgiChannel.speechDeactivateGrammar(String), AgiChannel.speechLoadGrammar(String, String)

speechDeactivateGrammar

public void speechDeactivateGrammar(java.lang.String name)
                             throws AgiException
Description copied from interface: AgiChannel
Deactivates the specified grammar.

Specified by:
speechDeactivateGrammar in interface AgiChannel
Parameters:
name - the name to the grammar to deactivate.
Throws:
AgiSpeechException - if the grammar cannot be deactivated.
AgiException
See Also:
AgiChannel.speechActivateGrammar(String)

speechRecognize

public SpeechRecognitionResult speechRecognize(java.lang.String prompt,
                                               int timeout)
                                        throws AgiException
Description copied from interface: AgiChannel
Plays the given prompt while listening for speech and DTMF.

Specified by:
speechRecognize in interface AgiChannel
Parameters:
prompt - the name of the file to stream, must not include extension.
timeout - the timeout in milliseconds to wait for user input.

0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).

Returns:
the recognition result
Throws:
AgiException

speechRecognize

public SpeechRecognitionResult speechRecognize(java.lang.String prompt,
                                               int timeout,
                                               int offset)
                                        throws AgiException
Description copied from interface: AgiChannel
Plays the given prompt while listening for speech and DTMF.

Specified by:
speechRecognize in interface AgiChannel
Parameters:
prompt - the name of the file to stream, must not include extension.
timeout - the timeout in milliseconds to wait for user input.

0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).

offset - the offset samples to skip before streaming, use 0 to start at the beginning.
Returns:
the recognition result
Throws:
AgiException

continueAt

public void continueAt(java.lang.String context,
                       java.lang.String extension,
                       java.lang.String priority)
                throws AgiException
Description copied from interface: AgiChannel
Defines the point in the dialplan where the call will continue when the AGI script returns.

This is a shortcut for calling AgiChannel.setContext(String), AgiChannel.setExtension(String) and AgiChannel.setPriority(String) in series.

Specified by:
continueAt in interface AgiChannel
Parameters:
context - the context for continuation upon exiting the application.
extension - the extension for continuation upon exiting the application.
priority - the priority or label for continuation upon exiting the application.
Throws:
AgiException
See Also:
AgiChannel.setContext(String), AgiChannel.setExtension(String), AgiChannel.setPriority(String)

Asterisk-Java

Copyright © 2004-2009 Stefan Reuter. All Rights Reserved.