using System;
using System.Text;
namespace AsterNET.FastAGI.Command
{
///
/// Returns the value of the given channel varible and understands complex
/// variable names and builtin variables, unlike the GetVariableCommand.
/// You can also use this command to use custom Asterisk functions. Syntax is "func(args)".
/// Returns 0 if the variable is not set or channel does not exist. Returns 1 if
/// the variable is set and returns the variable in parenthesis.
/// Example return code: 200 result=1 (testvariable)
/// Available since Asterisk 1.2
///
public class GetFullVariableCommand : AGICommand
{
private string varName;
private string channel;
///
/// Creates a new GetFullVariableCommand.
///
/// the name of the variable to retrieve.
public GetFullVariableCommand(string variable)
{
this.varName = variable;
}
///
/// Creates a new GetFullVariableCommand.
///
/// the name of the variable to retrieve.
/// the name of the channel.
public GetFullVariableCommand(string variable, string channel)
{
this.varName = variable;
this.channel = channel;
}
///
/// Get/Set the name of the variable to retrieve.
///
public string Variable
{
get { return varName; }
set { this.varName = value;}
}
///
/// Get/Set the name of the channel.
///
public string Channel
{
get { return channel; }
set { this.channel = value; }
}
public override string BuildCommand()
{
StringBuilder sb;
sb = new StringBuilder("GET FULL VARIABLE ");
sb.Append(EscapeAndQuote(varName));
if (channel != null)
{
sb.Append(" ");
sb.Append(EscapeAndQuote(channel));
}
return sb.ToString();
}
}
}