[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/fastagi AbstractAGIScript.java,1.14,
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-08-01 18:38:52
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25425/src/java/net/sf/asterisk/fastagi Modified Files: AbstractAGIScript.java Log Message: Deprecated execCommand(..) methods in favor of exec(...) in AbractAGIScript Added GetOptionCommand Index: AbstractAGIScript.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/AbstractAGIScript.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -p -r1.14 -r1.15 --- AbstractAGIScript.java 30 Jul 2005 20:37:29 -0000 1.14 +++ AbstractAGIScript.java 1 Aug 2005 18:38:43 -0000 1.15 @@ -20,6 +20,7 @@ import net.sf.asterisk.fastagi.command.A import net.sf.asterisk.fastagi.command.ChannelStatusCommand; import net.sf.asterisk.fastagi.command.ExecCommand; import net.sf.asterisk.fastagi.command.GetDataCommand; +import net.sf.asterisk.fastagi.command.GetOptionCommand; import net.sf.asterisk.fastagi.command.GetVariableCommand; import net.sf.asterisk.fastagi.command.HangupCommand; import net.sf.asterisk.fastagi.command.SayAlphaCommand; @@ -206,6 +207,51 @@ public abstract class AbstractAGIScript return reply.getResult(); } + // TODO add getOption() methods + + /** + * 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. + * + * @param file the name of the file to stream, must not include extension. + * @param escapeDigits contains the digits that the user is expected to + * press. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char getOption(AGIChannel channel, String file, + String escapeDigits) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new GetOptionCommand(file, escapeDigits)); + return reply.getResultCodeAsChar(); + } + + /** + * 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. + * + * @param file the name of the file to stream, must not include extension. + * @param escapeDigits contains the digits that the user is expected to + * press. + * @param timeout the timeout in seconds to wait if none of the defined + * esacpe digits was presses while streaming. + * @return the DTMF digit pressed or 0x0 if none was pressed. + */ + protected char getOption(AGIChannel channel, String file, + String escapeDigits, int timeout) throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new GetOptionCommand(file, escapeDigits, + timeout)); + return reply.getResultCodeAsChar(); + } + /** * Executes the given command. * @@ -213,6 +259,45 @@ public abstract class AbstractAGIScript * "Dial". * @return the return code of the application of -2 if the application was * not found. + * @since 0.2 + */ + protected int exec(AGIChannel channel, String application) + throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new ExecCommand(application)); + return reply.getResultCode(); + } + + /** + * Executes the given command. + * + * @param application the name of the application to execute, for example + * "Dial". + * @param options the parameters to pass to the application, for example + * "SIP/123". + * @return the return code of the application of -2 if the application was + * not found. + * @since 0.2 + */ + protected int exec(AGIChannel channel, String application, String options) + throws AGIException + { + AGIReply reply; + + reply = channel.sendCommand(new ExecCommand(application, options)); + return reply.getResultCode(); + } + + /** + * Executes the given command. + * + * @param application the name of the application to execute, for example + * "Dial". + * @return the return code of the application of -2 if the application was + * not found. + * @deprecated use {@see #exec(AGIChannel, String)} instead */ protected int execCommand(AGIChannel channel, String application) throws AGIException @@ -232,6 +317,7 @@ public abstract class AbstractAGIScript * "SIP/123". * @return the return code of the application of -2 if the application was * not found. + * @deprecated use {@see #exec(AGIChannel, String, String)} instead */ protected int execCommand(AGIChannel channel, String application, String options) throws AGIException |