[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/fastagi/command DatabaseDelCommand.j
Brought to you by:
srt
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/command In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24114/src/java/net/sf/asterisk/fastagi/command Added Files: DatabaseDelCommand.java SetPriorityCommand.java AGICommand.java DatabaseDelTreeCommand.java SayTimeCommand.java SayNumberCommand.java SetMusicOnCommand.java GetVariableCommand.java SetContextCommand.java DatabasePutCommand.java SetMusicOffCommand.java SetVariableCommand.java SetAutoHangupCommand.java GetDataCommand.java SayPhoneticCommand.java SendImageCommand.java ExecCommand.java SetExtensionCommand.java SendTextCommand.java HangupCommand.java SayDigitsCommand.java ChannelStatusCommand.java StreamFileCommand.java VerboseCommand.java SetCallerIdCommand.java TDDModeCommand.java WaitForDigitCommand.java AnswerCommand.java ReceiveCharCommand.java NoopCommand.java DatabaseGetCommand.java RecordFileCommand.java Log Message: Added initial stuff for fastagi support --- NEW FILE: DatabaseDelCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Deletes a family or specific keytree within a family in the Asterisk database.<br> * Returns 1 if successful, 0 otherwise. * * @author srt * @version $Id: DatabaseDelCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class DatabaseDelCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The family (or family of the keytree) to delete. */ private String family; /** * The keyTree to delete. */ private String keyTree; /** * Creates a new DatabaseDelCommand to delete a family. * * @param family the family to delete. */ public DatabaseDelCommand(String family) { this.family = family; this.keyTree = null; } /** * Creates a new DatabaseDelCommand to delete a keytree. * * @param family the family of the keytree to delete. * @param keyTree the keytree to delete. */ public DatabaseDelCommand(String family, String keyTree) { this.family = family; this.keyTree = keyTree; } /** * Returns the family (or family of the keytree) to delete. * * @return the family (or family of the keytree) to delete. */ public String getFamily() { return family; } /** * Sets the family (or family of the keytree) to delete. * * @param family the family (or family of the keytree) to delete. */ public void setFamily(String family) { this.family = family; } /** * Returns the the keytree to delete. * * @return the keytree to delete. */ public String getKeyTree() { return keyTree; } /** * Sets the keytree to delete. * * @param keyTree the keytree to delete. */ public void setKeyTree(String keyTree) { this.keyTree = keyTree; } public String buildCommand() { return "DATABASE DELTREE " + escapeAndQuote(family) + (keyTree == null ? "" : " " + escapeAndQuote(keyTree)); } } --- NEW FILE: SetPriorityCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sets the priority for continuation upon exiting the application. * * @author srt * @version $Id: SetPriorityCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetPriorityCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The priority for continuation upon exiting the application. */ private int priority; /** * Creates a new SetPriorityCommand. * * @param priority the priority for continuation upon exiting the application. */ public SetPriorityCommand(int priority) { this.priority = priority; } /** * Returns the priority for continuation upon exiting the application. * * @return the priority for continuation upon exiting the application. */ public int getPriority() { return priority; } /** * Sets the priority for continuation upon exiting the application. * * @param priority the priority for continuation upon exiting the application. */ public void setPriority(int priority) { this.priority = priority; } public String buildCommand() { return "SET PRIORITY " + priority; } } --- NEW FILE: AGICommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; import java.io.Serializable; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * * @author srt * @version $Id: AGICommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public abstract class AGICommand implements Serializable { /** * Serial version identifier. */ private static final long serialVersionUID = 3257849874518456633L; /** * Returns a string suitable to be sent to asterisk.<br> * * @return a string suitable to be sent to asterisk. */ public abstract String buildCommand(); protected String escapeAndQuote(String s) { String tmp; if (s == null) { return "\"\""; } tmp = s; tmp = tmp.replaceAll("\\\"", "\\\\\""); // escape quotes tmp = tmp.replaceAll("\\\n", ""); // filter newline return "\"" + tmp + "\""; // add quotes } public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); } public boolean equals(Object o) { return EqualsBuilder.reflectionEquals(this, o); } public int hashCode() { return HashCodeBuilder.reflectionHashCode(this); } } --- NEW FILE: DatabaseDelTreeCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Deletes an entry in the Asterisk database for a given family and key.<br> * Returns 1 if successful, 0 otherwise. * * @author srt * @version $Id: DatabaseDelTreeCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class DatabaseDelTreeCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The family of the key to delete. */ private String family; /** * The key to delete. */ private String key; /** * Creates a new DatabaseDelCommand. * * @param family the family of the key to delete. * @param key the key to delete. */ public DatabaseDelTreeCommand(String family, String key) { this.family = family; this.key = key; } /** * Returns the family of the key to delete. * * @return the family of the key to delete. */ public String getFamily() { return family; } /** * Sets the family of the key to delete. * * @param family the family of the key to delete. */ public void setFamily(String family) { this.family = family; } /** * Returns the the key to delete. * * @return the key to delete. */ public String getKey() { return key; } /** * Sets the key to delete. * * @param key the key to delete. */ public void setKey(String key) { this.key = key; } public String buildCommand() { return "DATABASE DEL " + escapeAndQuote(family) + " " + escapeAndQuote(key); } } --- NEW FILE: SayTimeCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this time except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Say a given time, returning early if any of the given DTMF digits are received on the channel.<br> * Time is the number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal * Time (UTC).<br> * Returns 0 if playback completes without a digit being pressed, or the ASCII numerical value of * the digit if one was pressed or -1 on error/hangup. * * @author srt * @version $Id: SayTimeCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SayTimeCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256721797012404276L; /** * The time to say in seconds since 00:00:00 on January 1, 1970. */ private long time; /** * When one of these digits is pressed the command returns. */ private String escapeDigits; /** * Creates a new SayTimeCommand. * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. */ public SayTimeCommand(long time) { this.time = time; this.escapeDigits = null; } /** * Creates a new SayTimeCommand. * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. * @param escapeDigits contains the digits that allow the user to interrupt this command. */ public SayTimeCommand(long time, String interruptDigits) { this.time = time; this.escapeDigits = interruptDigits; } /** * Returns the time to say in seconds since 00:00:00 on January 1, 1970. * * @return the time to say in seconds since 00:00:00 on January 1, 1970. */ public long getTime() { return time; } /** * Sets the time to say in seconds since 00:00:00 on January 1, 1970. * * @param time the time to say in seconds since 00:00:00 on January 1, 1970. */ public void setTime(long time) { this.time = time; } /** * Returns the digits that allow the user to interrupt this command. * * @return the digits that allow the user to interrupt this command. */ public String getEscapeDigits() { return escapeDigits; } /** * Sets the digits that allow the user to interrupt this command. * * @param escapeDigits the time that allow the user to interrupt this command or * <code>null</code> for none. */ public void setEscapeDigits(String escapeDigits) { this.escapeDigits = escapeDigits; } public String buildCommand() { return "SAY TIME " + time + " " + escapeAndQuote(escapeDigits); } } --- NEW FILE: SayNumberCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this number except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Say a given number, returning early if any of the given DTMF number are received on the channel.<br> * Returns 0 if playback completes without a digit being pressed, or the ASCII numerical value of * the digit if one was pressed or -1 on error/hangup. * * @author srt * @version $Id: SayNumberCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SayNumberCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3833744404153644087L; /** * The number to say. */ private String number; /** * When one of these number is pressed while streaming the command returns. */ private String interruptDigits; /** * Creates a new SayNumberCommand. * * @param number the number to say. */ public SayNumberCommand(String number) { this.number = number; this.interruptDigits = null; } /** * Creates a new SayNumberCommand. * * @param number the number to say. * @param interruptDigits contains the number that allow the user to interrupt this command. */ public SayNumberCommand(String number, String interruptDigits) { this.number = number; this.interruptDigits = interruptDigits; } /** * Returns the number to say. * * @return the number to say. */ public String getNumber() { return number; } /** * Sets the number to say. * * @param number the number to say. */ public void setNumber(String number) { this.number = number; } /** * Returns the number that allow the user to interrupt this command. * * @return the number that allow the user to interrupt this command. */ public String getInterruptDigits() { return interruptDigits; } /** * Sets the number that allow the user to interrupt this command. * * @param interruptDigits the number that allow the user to interrupt this command or * <code>null</code> for none. */ public void setInterruptDigits(String interruptDigits) { this.interruptDigits = interruptDigits; } public String buildCommand() { return "SAY NUMBER " + escapeAndQuote(number) + " " + escapeAndQuote(interruptDigits); } } --- NEW FILE: SetMusicOnCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Turns on music on hold on the current channel.<br> * Always returns 0. * * @author srt * @version $Id: SetMusicOnCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetMusicOnCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3762248656229053753L; /** * The music on hold class to play music from. */ private String musicOnHoldClass; /** * Creates a new SetMusicOnCommand playing music from the default music on hold class. */ public SetMusicOnCommand() { this.musicOnHoldClass = null; } /** * Returns the music on hold class to play music from. * * @return the music on hold class to play music from or <code>null</code> for the default * class. */ public String getMusicOnHoldClass() { return musicOnHoldClass; } /** * Sets the music on hold class to play music from. * * @param musicOnHoldClass the music on hold class to play music from or <code>null</code> for * the default class. */ public void setMusicOnHoldClass(String musicOnHoldClass) { this.musicOnHoldClass = musicOnHoldClass; } public String buildCommand() { return "SET MUSIC ON" + (musicOnHoldClass == null ? "" : " " + escapeAndQuote(musicOnHoldClass)); } } --- NEW FILE: GetVariableCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Returns the value of the given channel varible.<br> * Returns 0 if is not set. Returns 1 if the variable is set and returns the variable in * parenthesis.<br> * Example return code: 200 result=1 (testvariable) * * @author srt * @version $Id: GetVariableCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class GetVariableCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The name of the variable to retrieve. */ private String variable; /** * Creates a new GetVariableCommand. * * @param variable the name of the variable to retrieve. */ public GetVariableCommand(String variable) { this.variable = variable; } /** * Returns the name of the variable to retrieve. * * @return the the name of the variable to retrieve. */ public String getVariable() { return variable; } /** * Sets the name of the variable to retrieve. * * @param variable the name of the variable to retrieve. */ public void setVariable(String context) { this.variable = context; } public String buildCommand() { return "GET VARIABLE " + escapeAndQuote(variable); } } --- NEW FILE: SetContextCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sets the context for continuation upon exiting the application. * * @author srt * @version $Id: SetContextCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetContextCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The context for continuation upon exiting the application. */ private String context; /** * Creates a new SetPriorityCommand. * * @param context the context for continuation upon exiting the application. */ public SetContextCommand(String context) { this.context = context; } /** * Returns the context for continuation upon exiting the application. * * @return the context for continuation upon exiting the application. */ public String getContext() { return context; } /** * Sets the context for continuation upon exiting the application. * * @param context the context for continuation upon exiting the application. */ public void setContext(String context) { this.context = context; } public String buildCommand() { return "SET CONTEXT " + escapeAndQuote(context); } } --- NEW FILE: DatabasePutCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Adds or updates an entry in the Asterisk database for a given family, key, and value.<br> * Returns 1 if successful, 0 otherwise. * * @author srt * @version $Id: DatabasePutCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class DatabasePutCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The family of the key to set. */ private String family; /** * The key to set. */ private String key; /** * The value to set. */ private String value; /** * Creates a new DatabasePutCommand. * * @param family the family of the key to set. * @param key the key to set. * @param value the value to set. */ public DatabasePutCommand(String family, String key, String value) { this.family = family; this.key = key; this.value = value; } /** * Returns the family of the key to set. * * @return the family of the key to set. */ public String getFamily() { return family; } /** * Sets the family of the key to set. * * @param family the family of the key to set. */ public void setFamily(String family) { this.family = family; } /** * Returns the the key to set. * * @return the key to set. */ public String getKey() { return key; } /** * Sets the key to set. * * @param key the key to set. */ public void setKey(String key) { this.key = key; } /** * Returns the value to set. * * @return the value to set. */ public String getValue() { return value; } /** * Sets the value to set. * * @param value the value to set. */ public void setValue(String value) { this.value = value; } public String buildCommand() { return "DATABASE PUT " + escapeAndQuote(family) + " " + escapeAndQuote(key) + " " + escapeAndQuote(value); } } --- NEW FILE: SetMusicOffCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Turns off music on hold on the current channel.<br> * Always returns 0. * * @author srt * @version $Id: SetMusicOffCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetMusicOffCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3762248656229053753L; /** * Creates a new SetMusicOffCommand. */ public SetMusicOffCommand() { } public String buildCommand() { return "SET MUSIC OFF"; } } --- NEW FILE: SetVariableCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sets the given channel varible to the given value. * * @author srt * @version $Id: SetVariableCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetVariableCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The name of the variable to set. */ private String variable; /** * The value to set. */ private String value; /** * Creates a new GetVariableCommand. * * @param variable the name of the variable to set. * @param value the value to set. */ public SetVariableCommand(String variable, String value) { this.variable = variable; this.value = value; } /** * Returns the name of the variable to set. * * @return the the name of the variable to set. */ public String getVariable() { return variable; } /** * Sets the name of the variable to set. * * @param variable the name of the variable to set. */ public void setVariable(String context) { this.variable = context; } /** * Returns the value to set. * * @return the value to set. */ public String getValue() { return value; } /** * Sets the value to set. * * @param value the value to set. */ public void setValue(String value) { this.value = value; } public String buildCommand() { return "SET VARIABLE " + escapeAndQuote(variable) + " " + escapeAndQuote(value); } } --- NEW FILE: SetAutoHangupCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Cause the channel to automatically hangup at the given number of seconds in the future.<br> * Of course it can be hungup before then as well. Setting to 0 will cause the autohangup feature to * be disabled on this channel. * * @author srt * @version $Id: SetAutoHangupCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetAutoHangupCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3257562923458443314L; /** * The number of seconds before this channel is automatically hung up. */ private int time; /** * Creates a new SetAutoHangupCommand. * * @param time the number of seconds before this channel is automatically hung up.<br> * 0 disables the autohangup feature. */ public SetAutoHangupCommand(int time) { this.time = time; } /** * Returns the number of seconds before this channel is automatically hung up. * * @return the number of seconds before this channel is automatically hung up. */ public int getTime() { return time; } /** * Sets the number of seconds before this channel is automatically hung up. * * @param time the number of seconds before this channel is automatically hung up.<br> * 0 disables the autohangup feature. */ public void setTime(int timeout) { this.time = timeout; } public String buildCommand() { return "SET AUTOHANGUP " + time; } } --- NEW FILE: GetDataCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Stream the given file, and recieve DTMF data.<br> * Returns the digits recieved from the channel at the other end.<br> * Input ends when the timeout is reached, the maximum number of digits is read or the user presses #. * * @author srt * @version $Id: GetDataCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class GetDataCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3978141041352128820L; /** * The name of the file to stream. */ private String file; /** * The timeout to wait for data.<br> * 0 means standard timeout value, -1 means "ludicrous time" (essentially never times out). */ private int timeout; /** * The maximum number of digits to read.<br> * Must be in [1..1024]. */ private int maxDigits; /** * Creates a new GetDataCommand with default timeout and maxDigits set to 1024. * * @param file the name of the file to stream, must not include extension. */ public GetDataCommand(String file) { this.file = file; this.timeout = 0; this.maxDigits = 1024; } /** * Creates a new GetDataCommand. * * @param file the name of the file to stream, must not include extension. * @param timeout the timeout to wait for data.<br> * 0 means standard timeout value, -1 means "ludicrous time" (essentially never times out). * @param maxDigits the maximum number of digits to read.<br> * Must be in [1..1024]. * * @throws IllegalArgumentException if maxDigits is not in [1..1024] */ public GetDataCommand(String file, int timeout, int maxDigits) throws IllegalArgumentException { if (maxDigits < 1 || maxDigits > 1024) { throw new IllegalArgumentException("maxDigits must be in [1..1024]"); } this.file = file; this.timeout = timeout; this.maxDigits = maxDigits; } /** * Returns the name of the file to stream. * * @return the name of the file to stream. */ public String getFile() { return file; } /** * Sets the name of the file to stream. * * @param file the name of the file to stream, must not include extension. */ public void setFile(String file) { this.file = file; } /** * Returns the timeout to wait for data. * * @return the timeout to wait for data. */ public int getTimeout() { return timeout; } /** * Sets the timeout to wait for data. * * @param timeout the timeout to wait for data.<br> * 0 means standard timeout value, -1 means "ludicrous time" (essentially never times out). */ public void setTimeout(int timeout) { this.timeout = timeout; } /** * Returns the maximum number of digits to read. * * @return the maximum number of digits to read. */ public int getMaxDigits() { return maxDigits; } /** * Sets the maximum number of digits to read. * * @param maxDigits the maximum number of digits to read.<br> * Must be in [1..1024]. * * @throws IllegalArgumentException if maxDigits is not in [1..1024] */ public void setMaxDigits(int maxDigits) throws IllegalArgumentException { if (maxDigits < 1 || maxDigits > 1024) { throw new IllegalArgumentException("maxDigits must be in [1..1024]"); } this.maxDigits = maxDigits; } public String buildCommand() { return "GET DATA " + escapeAndQuote(file) + " " + timeout + " " + maxDigits; } } --- NEW FILE: SayPhoneticCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this text except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Say a given character string with phonetics, returning early if any of the given DTMF digits are * received on the channel.<br> * Returns 0 if playback completes without a digit being pressed, or the ASCII numerical value of * the digit if one was pressed or -1 on error/hangup. * * @author srt * @version $Id: SayPhoneticCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SayPhoneticCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256721797012404276L; /** * The text to say. */ private String text; /** * When one of these digits is pressed the command returns. */ private String escapeDigits; /** * Creates a new SayPhonticCommand. * * @param text the text to say. */ public SayPhoneticCommand(String text) { this.text = text; this.escapeDigits = null; } /** * Creates a new SayPhoneticCommand. * * @param text the text to say. * @param escapeDigits contains the digits that allow the user to interrupt this command. */ public SayPhoneticCommand(String text, String interruptDigits) { this.text = text; this.escapeDigits = interruptDigits; } /** * Returns the text to say. * * @return the text to say. */ public String getText() { return text; } /** * Sets the text to say. * * @param text the text to say. */ public void setText(String text) { this.text = text; } /** * Returns the digits that allow the user to interrupt this command. * * @return the digits that allow the user to interrupt this command. */ public String getEscapeDigits() { return escapeDigits; } /** * Sets the digits that allow the user to interrupt this command. * * @param escapeDigits the text that allow the user to interrupt this command or * <code>null</code> for none. */ public void setEscapeDigits(String escapeDigits) { this.escapeDigits = escapeDigits; } public String buildCommand() { return "SAY PHONETIC " + escapeAndQuote(text) + " " + escapeAndQuote(escapeDigits); } } --- NEW FILE: SendImageCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sends the given image on a channel.<br> * Most channels do not support the transmission of images.<br> * Returns 0 if image is sent, or if the channel does not support image transmission. Returns -1 * only on error/hangup.<br> * Image names should not include extensions. * * @author srt * @version $Id: SendImageCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SendImageCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3904959746380281145L; /** * The name of the image to send. */ private String image; /** * Creates a new SendImageCommand. * * @param image the image to send, should not include extension. */ public SendImageCommand(String image) { this.image = image; } /** * Returns the image to send. * * @return the image to send. */ public String getImage() { return image; } /** * Sets the image to send. * * @param image the image to send, should not include extension. */ public void setImage(String image) { this.image = image; } public String buildCommand() { return "SEND IMAGE " + escapeAndQuote(image); } } --- NEW FILE: ExecCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Executes an application with the given options.<br> * Returns whatever the application returns, or -2 on failure to find application. * * @author srt * @version $Id: ExecCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class ExecCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3904959746380281145L; /** * The name of the application to execute. */ private String application; /** * The options to pass to the application. */ private String options; /** * Creates a new ExecCommand. * * @param application the name of the application to execute. */ public ExecCommand(String application) { this.application = application; } /** * Creates a new ExecCommand. * * @param application the name of the application to execute. * @param options the options to pass to the application. */ public ExecCommand(String application, String options) { this.application = application; this.options = options; } /** * Returns the name of the application to execute. * * @return the name of the application to execute. */ public String getApplication() { return application; } /** * Sets the name of the application to execute. * * @param application the name of the application to execute. */ public void setApplication(String channel) { this.application = channel; this.options = null; } /** * Returns the options to pass to the application. * * @return the options to pass to the application. */ public String getOptions() { return options; } /** * Sets the options to pass to the application. * * @param options the options to pass to the application. */ public void setOptions(String options) { this.options = options; } public String buildCommand() { return "EXEC " + escapeAndQuote(application) + " " + escapeAndQuote(options); } } --- NEW FILE: SetExtensionCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sets the extension for continuation upon exiting the application. * * @author srt * @version $Id: SetExtensionCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SetExtensionCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3256719598056387384L; /** * The extension for continuation upon exiting the application. */ private String extension; /** * Creates a new SetPriorityCommand. * * @param extension the extension for continuation upon exiting the application. */ public SetExtensionCommand(String extension) { this.extension = extension; } /** * Returns the extension for continuation upon exiting the application. * * @return the extension for continuation upon exiting the application. */ public String getExtension() { return extension; } /** * Sets the extension for continuation upon exiting the application. * * @param extension the extension for continuation upon exiting the application. */ public void setExtension(String extension) { this.extension = extension; } public String buildCommand() { return "SET EXTENSION " + escapeAndQuote(extension); } } --- NEW FILE: SendTextCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Sends the given text on a channel.<br> * Most channels do not support the transmission of text.<br> * Returns 0 if text is sent, or if the channel does not support text transmission. Returns -1 only * on error/hangup. * * @author srt * @version $Id: SendTextCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SendTextCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3904959746380281145L; /** * The text to send. */ private String text; /** * Creates a new SendTextCommand. * * @param text the text to send. */ public SendTextCommand(String text) { this.text = text; } /** * Returns the text to send. * * @return the text to send. */ public String getText() { return text; } /** * Sets the text to send. * * @param text the text to send. */ public void setText(String text) { this.text = text; } public String buildCommand() { return "SEND TEXT " + escapeAndQuote(text); } } --- NEW FILE: HangupCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Hangs up the specified channel. If no channel name is given, hangs up the current channel. * * @author srt * @version $Id: HangupCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class HangupCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3904959746380281145L; /** * The name of the channel to hangup or <code>null</code> for the current channel. */ private String channel; /** * Creates a new HangupCommand that hangs up the current channel. */ public HangupCommand() { this.channel = null; } /** * Creates a new HangupCommand that hangs up the given channel. * * @param channel the name of the channel to hangup. */ public HangupCommand(String channel) { this.channel = channel; } /** * Returns the name of the channel to hangup. * * @return the name of the channel to hangup or <code>null</code> for the current channel. */ public String getChannel() { return channel; } /** * Sets the name of the channel to hangup. * * @param channel the name of the channel to hangup or <code>null</code> for the current * channel. */ public void setChannel(String channel) { this.channel = channel; } public String buildCommand() { return "HANGUP" + (channel == null ? "" : " " + escapeAndQuote(channel)); } } --- NEW FILE: SayDigitsCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this number except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Say a given digit string, returning early if any of the given DTMF number are received on the * channel.<br> * Returns 0 if playback completes without a digit being pressed, or the ASCII numerical value of * the digit if one was pressed or -1 on error/hangup. * * @author srt * @version $Id: SayDigitsCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class SayDigitsCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3907207173934101552L; /** * The number to say. */ private String number; /** * When one of these digits is pressed while saying the number the command returns. */ private String escapeDigits; /** * Creates a new SayDigitsCommand. * * @param number the number to say. */ public SayDigitsCommand(String digits) { this.number = digits; this.escapeDigits = null; } /** * Creates a new SayDigitsCommand. * * @param number the number to say. * @param escapeDigits the digits that allow the user to interrupt this command. */ public SayDigitsCommand(String number, String escapeDigits) { this.number = number; this.escapeDigits = escapeDigits; } /** * Returns the number to say. * * @return the number to say. */ public String getNumber() { return number; } /** * Sets the number to say. * * @param number the number to say. */ public void setNumber(String number) { this.number = number; } /** * Returns the digits that allow the user to interrupt this command. * * @return the digits that allow the user to interrupt this command. */ public String getEscapeDigits() { return escapeDigits; } /** * Sets the digits that allow the user to interrupt this command. * * @param escapeDigits the digits that allow the user to interrupt this command or * <code>null</code> for none. */ public void setEscapeDigits(String escapeDigits) { this.escapeDigits = escapeDigits; } public String buildCommand() { return "STREAM DIGITS " + escapeAndQuote(number) + " " + escapeAndQuote(escapeDigits); } } --- NEW FILE: ChannelStatusCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Returns the status of the specified channel. If no channel name is given the returns the status * of the current channel.<br> * Return values: * <ul> * <li>0 Channel is down and available * <li>1 Channel is down, but reserved * <li>2 Channel is off hook * <li>3 Digits (or equivalent) have been dialed * <li>4 Line is ringing * <li>5 Remote end is ringing * <li>6 Line is up * <li>7 Line is busy * </ul> * * @author srt * @version $Id: ChannelStatusCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class ChannelStatusCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3904959746380281145L; /** * The name of the channel to query or <code>null</code> for the current channel. */ private String channel; /** * Creates a new ChannelStatusCommand that queries the current channel. */ public ChannelStatusCommand() { this.channel = null; } /** * Creates a new ChannelStatusCommand that queries the given channel. * * @param channel the name of the channel to query. */ public ChannelStatusCommand(String channel) { this.channel = channel; } /** * Returns the name of the channel to query. * * @return the name of the channel to query or <code>null</code> for the current channel. */ public String getChannel() { return channel; } /** * Sets the name of the channel to query. * * @param channel the name of the channel to query or <code>null</code> for the current * channel. */ public void setChannel(String channel) { this.channel = channel; } public String buildCommand() { return "CHANNEL STATUS" + (channel == null ? "" : " " + escapeAndQuote(channel)); } } --- NEW FILE: StreamFileCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package net.sf.asterisk.fastagi.command; /** * Plays the given file, allowing playback to be interrupted by the given digits, if any.<br> * If offset is provided then the audio will seek to sample offset before play starts.<br> * Returns 0 if playback completes without a digit being pressed, or the ASCII numerical value of * the digit if one was pressed, or -1 on error or if the channel was disconnected. <br> * Remember, the file extension must not be included in the filename. * * @author srt * @version $Id: StreamFileCommand.java,v 1.1 2005/03/05 22:46:58 srt Exp $ */ public class StreamFileCommand extends AGICommand { /** * Serial version identifier. */ private static final long serialVersionUID = 3978141041352128820L; /** * The name of the file to stream. */ private String file; /** * When one of these digits is pressed while streaming the command returns. */ private String escapeDigits; /** * The offset samples to skip before streaming. */ private int offset; /** * Creates a new StreamFileCommand, streaming from the beginning. * * @param file the name of the file to stream, must not include extension. */ public StreamFileCommand(String file) { this.file = file; this.escapeDigits = null; this.offset = -1; } /** * Creates a new StreamFileCommand, streaming from the beginning. * * @param file the name of the file to stream, must not include extension. * @param escapeDigits contains the digits that allow the user to interrupt this command. */ public StreamFileCommand(String file, String escapeDigits) { this.file = file; this.escapeDigits = escapeDigits; this.offset = -1; } /** * Creates a new StreamFileCommand, streaming from the given offset. * * @param file the name of the file to stream, must not include extension. * @param escapeDigits contains the digits that allow the user to interrupt this command. Maybe * <code>null</code> if you don't want the user to interrupt. * @param offset the offset samples to skip before streaming. */ public StreamFileCommand(String file, String escapeDigits, int offset) { this.offset = offset; this.escapeDigits = escapeDigits; this.offset = offset; } /** * Returns the name of the file to stream. * * @return the name of the file to stream. */ public String getFile() { return file; } /** * Sets the name of the file to stream. * * @param file the name of the file to stream, must not include extension. */ public void setFile(String file) { this.file = file; } /** * Returns the digits that allow the user to interrupt this command. * * @return the digits that allow the user to interrupt this command. */ public String getEscapeDigits() { return escapeDigits; } /** * Sets the digits that allow the user to interrupt this command. * * @param escapeDigits the digits that allow the user to interrupt this command or * <code>null</code> for none. */ public void setEscapeDigits(String escapeDigits) { this.escapeDigits = escapeDigits; } /** * Returns the offset samples to skip before streaming. * * @return the offset samples to skip before streaming. */ public int getOffset() { return offset; } /** * Sets the offset samples to skip before streaming. * * @param offset the offset samples to skip before streaming. */ public void setOffset(int offset) { this.offset = offset; } public String buildCommand() { return "STREAM FILE " + escapeAndQuote(file) + " " + escapeAndQuote(escapeDigits) + (offset < 0 ? "" : " " + offset); } } --- NEW FILE: VerboseCommand.java --- /* * Copyright 2004-2005 Stefan Reuter * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apach... [truncated message content] |