From ba42c2f06f5a371998e85e4290acb3a73405a483 Mon Sep 17 00:00:00 2001 From: skrusty Date: Sat, 3 Jan 2015 15:37:29 +0000 Subject: [PATCH] Large code cleanup, see change log --- Asterisk.2013/Asterisk.NET/Common.cs | 93 +- .../Asterisk.NET/FastAGI/AGIChannel.cs | 93 +- .../FastAGI/AGIConnectionHandler.cs | 184 +- .../Asterisk.NET/FastAGI/AGIReader.cs | 147 +- .../Asterisk.NET/FastAGI/AGIReply.cs | 612 ++++--- .../Asterisk.NET/FastAGI/AGIRequest.cs | 1006 +++++------ .../Asterisk.NET/FastAGI/AGIWriter.cs | 52 +- .../Asterisk.NET/FastAGI/AsteriskFastAGI.cs | 451 ++--- .../Asterisk.NET/FastAGI/MappingStrategy.cs | 209 +-- Asterisk.2013/Asterisk.NET/Helper.cs | 1518 +++++++++-------- Asterisk.2013/Asterisk.NET/IParseSupport.cs | 19 +- Asterisk.2013/Asterisk.NET/Logger.cs | 499 +++--- .../Asterisk.NET/Manager/Action/AGIAction.cs | 34 +- .../Manager/Action/AOCMessageAction.cs | 146 +- .../Manager/Action/AbsoluteTimeoutAction.cs | 128 +- .../Action/AgentCallbackLoginAction.cs | 182 +- .../Manager/Action/AgentLogoffAction.cs | 159 +- .../Manager/Action/AgentsAction.cs | 68 +- .../Manager/Action/AtxferAction.cs | 59 +- .../Manager/Action/BridgeAction.cs | 42 +- .../Manager/Action/ChallengeAction.cs | 85 +- .../Manager/Action/ChangeMonitorAction.cs | 128 +- .../Manager/Action/CommandAction.cs | 81 +- .../Manager/Action/ConfbridgeKickAction.cs | 49 +- .../Manager/Action/ConfbridgeListAction.cs | 45 +- .../Action/ConfbridgeListRoomsAction.cs | 34 +- .../Manager/Action/ConfbridgeLockAction.cs | 45 +- .../Manager/Action/ConfbridgeMuteAction.cs | 49 +- .../ConfbridgeSetSingleVideoSrcAction.cs | 47 +- .../Action/ConfbridgeStartRecordAction.cs | 57 +- .../Action/ConfbridgeStopRecordAction.cs | 45 +- .../Manager/Action/ConfbridgeUnlockAction.cs | 45 +- .../Manager/Action/ConfbridgeUnmuteAction.cs | 49 +- .../Manager/Action/CoreSettingsAction.cs | 16 +- .../Manager/Action/CoreShowChannelsAction.cs | 16 +- .../Manager/Action/CoreStatusAction.cs | 16 +- .../Manager/Action/CreateConfigAction.cs | 30 +- .../Manager/Action/DBDelAction.cs | 55 +- .../Manager/Action/DBDelTreeAction.cs | 59 +- .../Manager/Action/DBGetAction.cs | 116 +- .../Manager/Action/DBPutAction.cs | 105 +- .../Manager/Action/EventsAction.cs | 86 +- .../Manager/Action/ExtensionStateAction.cs | 73 +- .../Manager/Action/GetConfigAction.cs | 82 +- .../Manager/Action/GetVarAction.cs | 105 +- .../Manager/Action/HangupAction.cs | 69 +- .../Manager/Action/ListCommandsAction.cs | 12 +- .../Manager/Action/LoginAction.cs | 233 ++- .../Manager/Action/LogoffAction.cs | 35 +- .../Manager/Action/MailboxCountAction.cs | 94 +- .../Manager/Action/MailboxStatusAction.cs | 100 +- .../Manager/Action/ManagerAction.cs | 118 +- .../Manager/Action/ManagerActionEvent.cs | 30 +- .../Manager/Action/ManagerActionResponse.cs | 33 +- .../Manager/Action/MonitorAction.cs | 231 ++- .../Manager/Action/OriginateAction.cs | 417 +++-- .../Asterisk.NET/Manager/Action/ParkAction.cs | 101 +- .../Manager/Action/ParkedCallsAction.cs | 46 +- .../Asterisk.NET/Manager/Action/PingAction.cs | 37 +- .../Manager/Action/ProxyAction.cs | 12 +- .../Manager/Action/QueueAddAction.cs | 208 +-- .../Manager/Action/QueueLogAction.cs | 60 +- .../Manager/Action/QueuePauseAction.cs | 197 +-- .../Manager/Action/QueuePenaltyAction.cs | 42 +- .../Manager/Action/QueueReloadAction.cs | 51 +- .../Manager/Action/QueueRemoveAction.cs | 100 +- .../Manager/Action/QueueResetAction.cs | 24 +- .../Manager/Action/QueueRuleAction.cs | 20 +- .../Manager/Action/QueueStatusAction.cs | 114 +- .../Manager/Action/RedirectAction.cs | 171 +- .../Manager/Action/SIPPeersAction.cs | 47 +- .../Manager/Action/SIPShowPeerAction.cs | 81 +- .../Manager/Action/SetCDRUserFieldAction.cs | 143 +- .../Manager/Action/SetVarAction.cs | 153 +- .../Manager/Action/StatusAction.cs | 51 +- .../Manager/Action/StopMonitorAction.cs | 99 +- .../Manager/Action/UpdateConfigAction.cs | 321 ++-- .../Manager/Action/ZapDNDOffAction.cs | 71 +- .../Manager/Action/ZapDNDOnAction.cs | 72 +- .../Manager/Action/ZapDialOffhookAction.cs | 87 +- .../Manager/Action/ZapHangupAction.cs | 73 +- .../Manager/Action/ZapShowChannelsAction.cs | 52 +- .../Manager/Action/ZapTransferAction.cs | 42 +- .../Asterisk.NET/Manager/AsteriskVersion.cs | 26 +- .../Manager/Event/AGIExecEvent.cs | 70 +- .../Manager/Event/AbstractAgentEvent.cs | 58 +- .../Manager/Event/AbstractMeetmeEvent.cs | 42 +- .../Manager/Event/AbstractParkedCallEvent.cs | 75 +- .../Manager/Event/AbstractQueueMemberEvent.cs | 47 +- .../Manager/Event/AgentCallbackLoginEvent.cs | 43 +- .../Manager/Event/AgentCallbackLogoffEvent.cs | 116 +- .../Manager/Event/AgentCalledEvent.cs | 124 +- .../Manager/Event/AgentCompleteEvent.cs | 61 +- .../Manager/Event/AgentConnectEvent.cs | 60 +- .../Manager/Event/AgentLoginEvent.cs | 44 +- .../Manager/Event/AgentLogoffEvent.cs | 49 +- .../Asterisk.NET/Manager/Event/AgentsEvent.cs | 128 +- .../Asterisk.NET/Manager/Event/AlarmEvent.cs | 54 +- .../Manager/Event/AsyncAGIEvent.cs | 54 +- .../Asterisk.NET/Manager/Event/CdrEvent.cs | 152 +- .../Manager/Event/ChannelReloadEvent.cs | 69 +- .../Manager/Event/ChannelUpdateEvent.cs | 94 +- .../Manager/Event/ConnectEvent.cs | 36 +- .../Manager/Event/DBGetResponseEvent.cs | 64 +- .../Manager/Event/DNDStateEvent.cs | 59 +- .../Asterisk.NET/Manager/Event/DTMFEvent.cs | 56 +- .../Manager/Event/FaxReceivedEvent.cs | 134 +- .../Asterisk.NET/Manager/Event/HoldEvent.cs | 34 +- .../Manager/Event/HoldedCallEvent.cs | 78 +- .../Asterisk.NET/Manager/Event/JabberEvent.cs | 38 +- .../Manager/Event/JitterBufStatsEvent.cs | 144 +- .../Asterisk.NET/Manager/Event/JoinEvent.cs | 68 +- .../Manager/Event/LogChannelEvent.cs | 97 +- .../Manager/Event/MasqueradeEvent.cs | 51 +- .../Manager/Event/MeetmeJoinEvent.cs | 36 +- .../Manager/Event/MeetmeLeaveEvent.cs | 43 +- .../Manager/Event/MeetmeMuteEvent.cs | 22 +- .../Manager/Event/MeetmeTalkRequestEvent.cs | 22 +- .../Manager/Event/MeetmeTalkingEvent.cs | 28 +- .../Manager/Event/MessageWaitingEvent.cs | 80 +- .../Manager/Event/MobileStatusEvent.cs | 39 +- .../Manager/Event/ModuleLoadReportEvent.cs | 40 +- .../Manager/Event/NewAccountCodeEvent.cs | 33 +- .../Manager/Event/NewCallerIdEvent.cs | 140 +- .../Asterisk.NET/Manager/IResponseHandler.cs | 43 +- .../Asterisk.NET/Manager/ManagerReader.cs | 144 +- .../Asterisk.NET/Manager/Originate.cs | 378 ++-- .../Manager/Response/ChallengeResponse.cs | 39 +- .../Manager/Response/CommandResponse.cs | 41 +- .../Response/ExtensionStateResponse.cs | 61 +- .../Manager/Response/GetConfigResponse.cs | 198 ++- .../Manager/Response/MailboxCountResponse.cs | 72 +- .../Manager/Response/MailboxStatusResponse.cs | 58 +- .../Manager/Response/ManagerError.cs | 34 +- .../Manager/Response/ManagerResponse.cs | 413 ++--- .../Manager/Response/OriginateResponse.cs | 207 ++- .../Manager/ResponseEventHandler.cs | 147 +- .../Asterisk.NET/Manager/ResponseEvents.cs | 83 +- .../Asterisk.NET/Manager/ResponseHandler.cs | 95 +- Asterisk.2013/Asterisk.NET/Util/MD5Support.cs | 181 +- Asterisk.2013/ChangeLog.txt | 3 + 141 files changed, 7393 insertions(+), 8578 deletions(-) diff --git a/Asterisk.2013/Asterisk.NET/Common.cs b/Asterisk.2013/Asterisk.NET/Common.cs index d8c5612..66a089a 100644 --- a/Asterisk.2013/Asterisk.NET/Common.cs +++ b/Asterisk.2013/Asterisk.NET/Common.cs @@ -1,55 +1,66 @@ using System; -using System.Text.RegularExpressions; using System.Globalization; +using System.Text.RegularExpressions; namespace AsterNET { - public static class Common - { - #region Manager API Constants + public static class Common + { + #region Manager API Constants - /// The hostname to use if none is provided. - public const string DEFAULT_HOSTNAME = "localhost"; - /// The port to use if none is provided. - public const int DEFAULT_PORT = 5038; - /// Line separator - public const string LINE_SEPARATOR = "\r\n"; + /// The hostname to use if none is provided. + public const string DEFAULT_HOSTNAME = "localhost"; - public static Regex ASTERISK_VERSION = new Regex("^Asterisk\\s+([0-9]+.[0-9]+.[0-9]+).*", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static Regex SHOW_VERSION_FILES_PATTERN = new Regex("^([\\S]+)\\s+Revision: ([0-9\\.]+)"); - public static char[] RESPONSE_KEY_VALUE_SEPARATOR = new char[] { ':' }; - public static char[] MINUS_SEPARATOR = new char[] { '-' }; - public static char INTERNAL_ACTION_ID_DELIMITER = '#'; - /// Variables delimiter - public static char[] VAR_DELIMITER = new char[] { '|' }; - public static IFormatProvider CultureInfoEn = new CultureInfo("en-US", false); + /// The port to use if none is provided. + public const int DEFAULT_PORT = 5038; - #endregion + /// Line separator + public const string LINE_SEPARATOR = "\r\n"; - #region AGI Constants + public static Regex ASTERISK_VERSION = new Regex("^Asterisk\\s+([0-9]+.[0-9]+.[0-9]+).*", + RegexOptions.Compiled | RegexOptions.IgnoreCase); - /// The default AGI bind port. - public const int AGI_BIND_PORT = 4573; - /// The default AGI thread pool size. - public const int AGI_POOL_SIZE = 10; - /// The default AGI bind address. - public const string AGI_BIND_ADDRESS = "0.0.0.0"; + public static Regex SHOW_VERSION_FILES_PATTERN = new Regex("^([\\S]+)\\s+Revision: ([0-9\\.]+)"); + public static char[] RESPONSE_KEY_VALUE_SEPARATOR = {':'}; + public static char[] MINUS_SEPARATOR = {'-'}; + public static char INTERNAL_ACTION_ID_DELIMITER = '#'; - public const string AGI_DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping.resources"; - public const string AGI_END_OF_PROPER_USAGE = "520 End of proper usage."; + /// Variables delimiter + public static char[] VAR_DELIMITER = {'|'}; - public const int AGI_DEFAULT_MAX_DIGITS = 1024; - public const int AGI_DEFAULT_TIMEOUT = 0; + public static IFormatProvider CultureInfoEn = new CultureInfo("en-US", false); - public static Regex AGI_STATUS_PATTERN = new Regex("^(\\d{3})[ -]", RegexOptions.Compiled); - public static Regex AGI_RESULT_PATTERN = new Regex("^200 result= *(\\S+)", RegexOptions.Compiled); - public static Regex AGI_PARENTHESIS_PATTERN = new Regex("^200 result=\\S* +\\((.*)\\)", RegexOptions.Compiled); - public static Regex AGI_ADDITIONAL_ATTRIBUTES_PATTERN = new Regex("^200 result=\\S* +(\\(.*\\) )?(.+)$", RegexOptions.Compiled); - public static Regex AGI_ADDITIONAL_ATTRIBUTE_PATTERN = new Regex("(\\S+)=(\\S+)", RegexOptions.Compiled); - public static Regex AGI_SYNOPSIS_PATTERN = new Regex("^\\s*Usage:\\s*(.*)\\s*$", RegexOptions.Compiled); - public static Regex AGI_SCRIPT_PATTERN = new Regex("^([^\\?]*)\\?(.*)$"); - public static Regex AGI_PARAMETER_PATTERN = new Regex("^(.*)=(.*)$"); + #endregion - #endregion - } -} + #region AGI Constants + + /// The default AGI bind port. + public const int AGI_BIND_PORT = 4573; + + /// The default AGI thread pool size. + public const int AGI_POOL_SIZE = 10; + + /// The default AGI bind address. + public const string AGI_BIND_ADDRESS = "0.0.0.0"; + + public const string AGI_DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping.resources"; + public const string AGI_END_OF_PROPER_USAGE = "520 End of proper usage."; + + public const int AGI_DEFAULT_MAX_DIGITS = 1024; + public const int AGI_DEFAULT_TIMEOUT = 0; + + public static Regex AGI_STATUS_PATTERN = new Regex("^(\\d{3})[ -]", RegexOptions.Compiled); + public static Regex AGI_RESULT_PATTERN = new Regex("^200 result= *(\\S+)", RegexOptions.Compiled); + public static Regex AGI_PARENTHESIS_PATTERN = new Regex("^200 result=\\S* +\\((.*)\\)", RegexOptions.Compiled); + + public static Regex AGI_ADDITIONAL_ATTRIBUTES_PATTERN = new Regex("^200 result=\\S* +(\\(.*\\) )?(.+)$", + RegexOptions.Compiled); + + public static Regex AGI_ADDITIONAL_ATTRIBUTE_PATTERN = new Regex("(\\S+)=(\\S+)", RegexOptions.Compiled); + public static Regex AGI_SYNOPSIS_PATTERN = new Regex("^\\s*Usage:\\s*(.*)\\s*$", RegexOptions.Compiled); + public static Regex AGI_SCRIPT_PATTERN = new Regex("^([^\\?]*)\\?(.*)$"); + public static Regex AGI_PARAMETER_PATTERN = new Regex("^(.*)=(.*)$"); + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIChannel.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIChannel.cs index 18a0403..c439272 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIChannel.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIChannel.cs @@ -1,58 +1,61 @@ +using AsterNET.FastAGI.Command; +using AsterNET.IO; + namespace AsterNET.FastAGI { - /// - /// Default implementation of the AGIChannel interface. - /// - public class AGIChannel - { - private AGIWriter agiWriter; - private AGIReader agiReader; - private AGIReply agiReply; + /// + /// Default implementation of the AGIChannel interface. + /// + public class AGIChannel + { + private readonly bool _SC511_CAUSES_EXCEPTION; + private readonly bool _SCHANGUP_CAUSES_EXCEPTION; + private readonly AGIReader agiReader; + private readonly AGIWriter agiWriter; + private AGIReply agiReply; - private bool _SC511_CAUSES_EXCEPTION = false; - private bool _SCHANGUP_CAUSES_EXCEPTION = false; - - public AGIChannel(IO.SocketConnection socket, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) + public AGIChannel(SocketConnection socket, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) { - this.agiWriter = new AGIWriter(socket); - this.agiReader = new AGIReader(socket); + agiWriter = new AGIWriter(socket); + agiReader = new AGIReader(socket); - this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; - this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; + _SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; + _SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; } - public AGIChannel(AGIWriter agiWriter, AGIReader agiReader, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) - { - this.agiWriter = agiWriter; - this.agiReader = agiReader; + public AGIChannel(AGIWriter agiWriter, AGIReader agiReader, bool SC511_CAUSES_EXCEPTION, + bool SCHANGUP_CAUSES_EXCEPTION) + { + this.agiWriter = agiWriter; + this.agiReader = agiReader; - this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; - this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; - } + _SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; + _SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; + } - /// - /// Get last AGI Reply. - /// - public AGIReply LastReply - { - get { return agiReply; } - } + /// + /// Get last AGI Reply. + /// + public AGIReply LastReply + { + get { return agiReply; } + } - public AGIReply SendCommand(Command.AGICommand command) - { - agiWriter.SendCommand(command); - agiReply = agiReader.ReadReply(); - int status = agiReply.GetStatus(); - if (status == (int)AGIReplyStatuses.SC_INVALID_OR_UNKNOWN_COMMAND) - throw new InvalidOrUnknownCommandException(command.BuildCommand()); - else if (status == (int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX) - throw new InvalidCommandSyntaxException(agiReply.GetSynopsis(), agiReply.GetUsage()); - else if (status == (int)AGIReplyStatuses.SC_DEAD_CHANNEL && _SC511_CAUSES_EXCEPTION) + public AGIReply SendCommand(AGICommand command) + { + agiWriter.SendCommand(command); + agiReply = agiReader.ReadReply(); + int status = agiReply.GetStatus(); + if (status == (int) AGIReplyStatuses.SC_INVALID_OR_UNKNOWN_COMMAND) + throw new InvalidOrUnknownCommandException(command.BuildCommand()); + if (status == (int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX) + throw new InvalidCommandSyntaxException(agiReply.GetSynopsis(), agiReply.GetUsage()); + if (status == (int) AGIReplyStatuses.SC_DEAD_CHANNEL && _SC511_CAUSES_EXCEPTION) throw new AGIHangupException(); - else if ((status == 0) && agiReply.FirstLine == "HANGUP" && _SCHANGUP_CAUSES_EXCEPTION) + if ((status == 0) && agiReply.FirstLine == "HANGUP" && _SCHANGUP_CAUSES_EXCEPTION) throw new AGIHangupException(); - return agiReply; - } - } -} + return agiReply; + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIConnectionHandler.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIConnectionHandler.cs index 09beec6..2c0f2fb 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIConnectionHandler.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIConnectionHandler.cs @@ -1,122 +1,126 @@ using System; using System.IO; using System.Threading; +using AsterNET.FastAGI.Command; +using AsterNET.IO; namespace AsterNET.FastAGI { - /// - /// An AGIConnectionHandler is created and run by the AGIServer whenever a new - /// socket connection from an Asterisk Server is received.
- /// It reads the request using an AGIReader and runs the AGIScript configured to - /// handle this type of request. Finally it closes the socket connection. - ///
- public class AGIConnectionHandler - { + /// + /// An AGIConnectionHandler is created and run by the AGIServer whenever a new + /// socket connection from an Asterisk Server is received.
+ /// It reads the request using an AGIReader and runs the AGIScript configured to + /// handle this type of request. Finally it closes the socket connection. + ///
+ public class AGIConnectionHandler + { #if LOGGER - private Logger logger = Logger.Instance(); + private readonly Logger logger = Logger.Instance(); #endif - private static readonly LocalDataStoreSlot channel = Thread.AllocateDataSlot(); - private IO.SocketConnection socket; - private IMappingStrategy mappingStrategy; - private bool _SC511_CAUSES_EXCEPTION = false; - private bool _SCHANGUP_CAUSES_EXCEPTION = false; + private static readonly LocalDataStoreSlot _channel = Thread.AllocateDataSlot(); + private readonly SocketConnection socket; + private readonly IMappingStrategy mappingStrategy; + private readonly bool _SC511_CAUSES_EXCEPTION; + private readonly bool _SCHANGUP_CAUSES_EXCEPTION; - #region Channel - /// - /// Returns the AGIChannel associated with the current thread. - /// - /// the AGIChannel associated with the current thread or null if none is associated. - internal static AGIChannel Channel - { - get - { - return (AGIChannel) Thread.GetData(AGIConnectionHandler.channel); - } - } - #endregion + #region Channel - #region AGIConnectionHandler(socket, mappingStrategy) - /// - /// Creates a new AGIConnectionHandler to handle the given socket connection. - /// - /// the socket connection to handle. - /// the strategy to use to determine which script to run. - public AGIConnectionHandler(IO.SocketConnection socket, IMappingStrategy mappingStrategy, bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) - { - this.socket = socket; - this.mappingStrategy = mappingStrategy; - this._SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; - this._SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; - } - #endregion + /// + /// Returns the AGIChannel associated with the current thread. + /// + /// the AGIChannel associated with the current thread or null if none is associated. + internal static AGIChannel Channel + { + get { return (AGIChannel) Thread.GetData(_channel); } + } - public void Run() - { - try - { - AGIReader reader = new AGIReader(socket); - AGIWriter writer = new AGIWriter(socket); - AGIRequest request = reader.ReadRequest(); - AGIChannel channel = new AGIChannel(writer, reader, this._SC511_CAUSES_EXCEPTION, this._SCHANGUP_CAUSES_EXCEPTION); - AGIScript script = mappingStrategy.DetermineScript(request); - Thread.SetData(AGIConnectionHandler.channel, channel); + #endregion - if (script != null) - { + #region AGIConnectionHandler(socket, mappingStrategy) + + /// + /// Creates a new AGIConnectionHandler to handle the given socket connection. + /// + /// the socket connection to handle. + /// the strategy to use to determine which script to run. + public AGIConnectionHandler(SocketConnection socket, IMappingStrategy mappingStrategy, + bool SC511_CAUSES_EXCEPTION, bool SCHANGUP_CAUSES_EXCEPTION) + { + this.socket = socket; + this.mappingStrategy = mappingStrategy; + _SC511_CAUSES_EXCEPTION = SC511_CAUSES_EXCEPTION; + _SCHANGUP_CAUSES_EXCEPTION = SCHANGUP_CAUSES_EXCEPTION; + } + + #endregion + + public void Run() + { + try + { + var reader = new AGIReader(socket); + var writer = new AGIWriter(socket); + AGIRequest request = reader.ReadRequest(); + var channel = new AGIChannel(writer, reader, _SC511_CAUSES_EXCEPTION, _SCHANGUP_CAUSES_EXCEPTION); + AGIScript script = mappingStrategy.DetermineScript(request); + Thread.SetData(_channel, channel); + + if (script != null) + { #if LOGGER - logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); + logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); #endif - script.Service(request, channel); + script.Service(request, channel); #if LOGGER - logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); + logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name); #endif - } - else - { - string error; - error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script + "')"; - channel.SendCommand(new Command.VerboseCommand(error, 1)); + } + else + { + var error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script + + "')"; + channel.SendCommand(new VerboseCommand(error, 1)); #if LOGGER - logger.Error(error); + logger.Error(error); #endif - } - } - catch (AGIHangupException) - { - } - catch (IOException) - { - } - catch (AGIException ex) - { + } + } + catch (AGIHangupException) + { + } + catch (IOException) + { + } + catch (AGIException ex) + { #if LOGGER - logger.Error("AGIException while handling request", ex); + logger.Error("AGIException while handling request", ex); #else throw ex; #endif - } - catch (Exception ex) - { + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unexpected Exception while handling request", ex); + logger.Error("Unexpected Exception while handling request", ex); #else throw ex; #endif - } + } - Thread.SetData(AGIConnectionHandler.channel, null); - try - { - socket.Close(); - } + Thread.SetData(_channel, null); + try + { + socket.Close(); + } #if LOGGER - catch(IOException ex) - { - logger.Error("Error on close socket", ex); - } + catch (IOException ex) + { + logger.Error("Error on close socket", ex); + } #else catch { } #endif - } - } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIReader.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIReader.cs index 29f285d..3db6e63 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIReader.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIReader.cs @@ -1,89 +1,90 @@ -using System; -using System.IO; -using System.Collections; using System.Collections.Generic; +using System.IO; +using AsterNET.IO; namespace AsterNET.FastAGI { - public class AGIReader - { + public class AGIReader + { #if LOGGER - private Logger logger = Logger.Instance(); + private readonly Logger logger = Logger.Instance(); #endif - private IO.SocketConnection socket; - public AGIReader(IO.SocketConnection socket) - { - this.socket = socket; - } + private readonly SocketConnection socket; - public AGIRequest ReadRequest() - { - string line; - List lines = new List(); - try - { + public AGIReader(SocketConnection socket) + { + this.socket = socket; + } + + public AGIRequest ReadRequest() + { + var lines = new List(); + try + { #if LOGGER - logger.Info("AGIReader.ReadRequest():"); + logger.Info("AGIReader.ReadRequest():"); #endif - while ((line = socket.ReadLine()) != null) - { - if (line.Length == 0) - break; - lines.Add(line); + string line; + while ((line = socket.ReadLine()) != null) + { + if (line.Length == 0) + break; + lines.Add(line); #if LOGGER - logger.Info(line); + logger.Info(line); #endif - } - } - catch (IOException ex) - { - throw new AGINetworkException("Unable to read request from Asterisk: " + ex.Message, ex); - } + } + } + catch (IOException ex) + { + throw new AGINetworkException("Unable to read request from Asterisk: " + ex.Message, ex); + } - AGIRequest request = new AGIRequest(lines); + var request = new AGIRequest(lines) + { + LocalAddress = socket.LocalAddress, + LocalPort = socket.LocalPort, + RemoteAddress = socket.RemoteAddress, + RemotePort = socket.RemotePort + }; - request.LocalAddress = socket.LocalAddress; - request.LocalPort = socket.LocalPort; - request.RemoteAddress = socket.RemoteAddress; - request.RemotePort = socket.RemotePort; + return request; + } - return request; - } - - public AGIReply ReadReply() - { - string line; - string badSyntax = ((int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX).ToString(); + public AGIReply ReadReply() + { + string line; + var badSyntax = ((int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX).ToString(); - List lines = new List(); - try - { - line = socket.ReadLine(); - } - catch (IOException ex) - { - throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); - } - if (line == null) - throw new AGIHangupException(); + var lines = new List(); + try + { + line = socket.ReadLine(); + } + catch (IOException ex) + { + throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); + } + if (line == null) + throw new AGIHangupException(); - lines.Add(line); - // read synopsis and usage if statuscode is 520 - if (line.StartsWith(badSyntax)) - try - { - while ((line = socket.ReadLine()) != null) - { - lines.Add(line); - if (line.StartsWith(badSyntax)) - break; - } - } - catch (IOException ex) - { - throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); - } - return new AGIReply(lines); - } - } -} + lines.Add(line); + // read synopsis and usage if statuscode is 520 + if (line.StartsWith(badSyntax)) + try + { + while ((line = socket.ReadLine()) != null) + { + lines.Add(line); + if (line.StartsWith(badSyntax)) + break; + } + } + catch (IOException ex) + { + throw new AGINetworkException("Unable to read reply from Asterisk: " + ex.Message, ex); + } + return new AGIReply(lines); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIReply.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIReply.cs index f34ad80..72170a1 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIReply.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIReply.cs @@ -1,320 +1,366 @@ using System; -using System.Text; -using System.Text.RegularExpressions; using System.Collections; using System.Collections.Generic; +using System.Text; +using System.Text.RegularExpressions; namespace AsterNET.FastAGI { - #region Enum - AGIReplyStatuses - public enum AGIReplyStatuses - { - /// - /// Status code (200) indicating Asterisk successfully processed the AGICommand. - /// - SC_SUCCESS = 200, - /// - /// Status code (510) indicating Asterisk was unable to process the - /// AGICommand because there is no command with the given name available. - /// - SC_INVALID_OR_UNKNOWN_COMMAND = 510, + + #region Enum - AGIReplyStatuses + + public enum AGIReplyStatuses + { /// - /// Status code (511) indicating Asterisk was unable to process the - /// AGICommand because the channel is dead. + /// Status code (200) indicating Asterisk successfully processed the AGICommand. + /// + SC_SUCCESS = 200, + + /// + /// Status code (510) indicating Asterisk was unable to process the + /// AGICommand because there is no command with the given name available. + /// + SC_INVALID_OR_UNKNOWN_COMMAND = 510, + + /// + /// Status code (511) indicating Asterisk was unable to process the + /// AGICommand because the channel is dead. /// SC_DEAD_CHANNEL = 511, - /// - /// Status code (520) indicating Asterisk was unable to process the - /// AGICommand because the syntax used was not correct. This is most likely - /// due to missing required parameters or additional parameters sent that are - /// not understood.
- /// Ensure proper quoting of the parameters when you receive this status - /// code. - ///
- SC_INVALID_COMMAND_SYNTAX = 520 - } - #endregion - /// - /// Default implementation of the AGIReply interface. - /// - public class AGIReply - { - #region Variables - private Match matcher; - private List lines; - private string firstLine; - /// The result, that is the part directly following the "result=" string. - private string result; - /// The status code. - private int status; - /// Additional attributes contained in this reply, for example endpos. - private Dictionary attributes; - /// The contents of the parenthesis. - private string extra; - /// In case of status == 520 (invalid command syntax) this attribute contains the synopsis of the command. - private string synopsis; - /// In case of status == 520 (invalid command syntax) this attribute contains the usage of the command. - private string usage; - private bool extraCreated; - private bool synopsisCreated; - private bool attributesCreated; - private bool resultCreated; - private bool statusCreated; - #endregion + /// + /// Status code (520) indicating Asterisk was unable to process the + /// AGICommand because the syntax used was not correct. This is most likely + /// due to missing required parameters or additional parameters sent that are + /// not understood.
+ /// Ensure proper quoting of the parameters when you receive this status + /// code. + ///
+ SC_INVALID_COMMAND_SYNTAX = 520 + } - #region Constructor - AGIReply() - public AGIReply() - { - } - #endregion + #endregion - #region Constructor - AGIReply(lines) - public AGIReply(List lines) - { - this.lines = lines; - try - { - firstLine = lines[0]; - } - catch { } - } - #endregion + /// + /// Default implementation of the AGIReply interface. + /// + public class AGIReply + { + #region Variables - #region FirstLine - public string FirstLine - { - get { return firstLine; } - } - #endregion + private readonly string firstLine; + private readonly List lines; - #region Lines - public IList Lines - { - get { return lines; } - } - #endregion + /// Additional attributes contained in this reply, for example endpos. + private Dictionary attributes; - #region ResultCode - /// - /// Returns the return code (the result as int). - /// - /// the return code or -1 if the result is not an int. - public int ResultCode - { - get - { - string result; - result = GetResult(); - if (result == null) - return -1; - try - { - return Int32.Parse(result); - } - catch - { - return -1; - } - } - } - #endregion + private bool attributesCreated; - #region ResultCodeAsChar - /// - /// Returns the return code as character. - /// - /// the return code as character. - public char ResultCodeAsChar - { - get - { - int resultCode; - resultCode = ResultCode; - if (resultCode < 0) - return (char)(0x0); - return (char)resultCode; - } - } - #endregion + /// The contents of the parenthesis. + private string extra; - #region Extra - /// - /// Returns the text in parenthesis contained in this reply.
- /// The meaning of this property depends on the command sent. Sometimes it - /// contains a flag like "timeout" or "hangup" or - in case of the - /// GetVariableCommand - the value of the variable. - ///
- /// the text in the parenthesis or null if not set. - public string Extra - { - get - { - if (GetStatus() != (int)AGIReplyStatuses.SC_SUCCESS) - return null; + private bool extraCreated; + private Match matcher; - if (extraCreated) - return extra; + /// The result, that is the part directly following the "result=" string. + private string result; - matcher = Common.AGI_PARENTHESIS_PATTERN.Match(firstLine); - if (matcher.Success) - extra = matcher.Groups[1].Value; + private bool resultCreated; - extraCreated = true; - return extra; - } - } - #endregion + /// The status code. + private int status; - #region GetResult() - /// - /// Returns the result, that is the part directly following the "result=" string. - /// - /// the result. - public string GetResult() - { - if (resultCreated) - return result; + private bool statusCreated; - matcher = Common.AGI_RESULT_PATTERN.Match(firstLine); - if (matcher.Success) - result = matcher.Groups[1].Value; + /// In case of status == 520 (invalid command syntax) this attribute contains the synopsis of the command. + private string synopsis; - resultCreated = true; - return result; - } - #endregion + private bool synopsisCreated; - #region GetStatus() - /// - /// Returns the status code.
- /// Supported status codes are:
- /// 200 Success
- /// 510 Invalid or unknown command
- /// 520 Invalid command syntax
- ///
- /// the status code. - public int GetStatus() - { - if (statusCreated) - return status; - matcher = Common.AGI_STATUS_PATTERN.Match(firstLine); - if (matcher.Success) - status = Int32.Parse(matcher.Groups[1].Value); - statusCreated = true; - return status; - } - #endregion + /// In case of status == 520 (invalid command syntax) this attribute contains the usage of the command. + private string usage; - #region GetAttribute(name) - /// - /// Returns an additional attribute contained in the reply.
- /// For example the reply to the StreamFileCommand contains an additional - /// endpos attribute indicating the frame where the playback was stopped. - /// This can be retrieved by calling getAttribute("endpos") on the corresponding reply. - ///
- /// the name of the attribute to retrieve. The name is case insensitive. - /// the value of the attribute or null if it is not set. - public string GetAttribute(string name) - { - if (GetStatus() != (int)AGIReplyStatuses.SC_SUCCESS) - return null; + #endregion - if ("result".ToUpper().Equals(name.ToUpper())) - return GetResult(); + #region Constructor - AGIReply() - if (!attributesCreated) - { - matcher = Common.AGI_ADDITIONAL_ATTRIBUTES_PATTERN.Match(firstLine); - if (matcher.Success) - { - string s; - Match attributeMatcher; + public AGIReply() + { + } - attributes = new Dictionary(); - s = matcher.Groups[2].Value; - attributeMatcher = Common.AGI_ADDITIONAL_ATTRIBUTE_PATTERN.Match(s); - while (attributeMatcher.Success) - { - string key; - string value_Renamed; + #endregion - key = attributeMatcher.Groups[1].Value; - value_Renamed = attributeMatcher.Groups[2].Value; - attributes[key.ToLower(Helper.CultureInfo)] = value_Renamed; - } - } - attributesCreated = true; - } + #region Constructor - AGIReply(lines) - if (attributes == null || (attributes.Count == 0)) - return null; + public AGIReply(List lines) + { + this.lines = lines; + try + { + firstLine = lines[0]; + } + catch + { + } + } - return (string)attributes[name.ToLower(Helper.CultureInfo)]; - } - #endregion + #endregion - #region GetSynopsis() - /// - /// Returns the synopsis of the command sent if Asterisk expected a different - /// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). - /// - /// the synopsis of the command sent, null if there were no syntax errors. - public string GetSynopsis() - { - if (GetStatus() != (int)AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX) - return null; + #region FirstLine - if (!synopsisCreated) - { - if (lines.Count > 1) - { - string secondLine; - Match synopsisMatcher; + public string FirstLine + { + get { return firstLine; } + } - secondLine = ((string)lines[1]); - synopsisMatcher = Common.AGI_SYNOPSIS_PATTERN.Match(secondLine); - if (synopsisMatcher.Success) - synopsis = synopsisMatcher.Groups[1].Value; - } - synopsisCreated = true; + #endregion - StringBuilder sbUsage = new StringBuilder(); - string line; - for (int i = 2; i < lines.Count; i++) - { - line = ((string)lines[i]); - if (line == Common.AGI_END_OF_PROPER_USAGE) - break; - sbUsage.Append(line.Trim()); - sbUsage.Append(" "); - } - usage = sbUsage.ToString().Trim(); - } - return synopsis; - } - #endregion + #region Lines - #region GetUsage() - /// - /// Returns the usage of the command sent if Asterisk expected a different - /// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). - /// - /// - /// the usage of the command sent, - /// null if there were no syntax errors. - /// - public string GetUsage() - { - return usage; - } - #endregion + public IList Lines + { + get { return lines; } + } - #region ToString() - public override string ToString() - { - return Helper.ToString(this); - } - #endregion - } -} + #endregion + + #region ResultCode + + /// + /// Returns the return code (the result as int). + /// + /// the return code or -1 if the result is not an int. + public int ResultCode + { + get + { + string result; + result = GetResult(); + if (result == null) + return -1; + try + { + return Int32.Parse(result); + } + catch + { + return -1; + } + } + } + + #endregion + + #region ResultCodeAsChar + + /// + /// Returns the return code as character. + /// + /// the return code as character. + public char ResultCodeAsChar + { + get + { + int resultCode = ResultCode; + if (resultCode < 0) + return (char) (0x0); + return (char) resultCode; + } + } + + #endregion + + #region Extra + + /// + /// Returns the text in parenthesis contained in this reply.
+ /// The meaning of this property depends on the command sent. Sometimes it + /// contains a flag like "timeout" or "hangup" or - in case of the + /// GetVariableCommand - the value of the variable. + ///
+ /// the text in the parenthesis or null if not set. + public string Extra + { + get + { + if (GetStatus() != (int) AGIReplyStatuses.SC_SUCCESS) + return null; + + if (extraCreated) + return extra; + + matcher = Common.AGI_PARENTHESIS_PATTERN.Match(firstLine); + if (matcher.Success) + extra = matcher.Groups[1].Value; + + extraCreated = true; + return extra; + } + } + + #endregion + + #region GetResult() + + /// + /// Returns the result, that is the part directly following the "result=" string. + /// + /// the result. + public string GetResult() + { + if (resultCreated) + return result; + + matcher = Common.AGI_RESULT_PATTERN.Match(firstLine); + if (matcher.Success) + result = matcher.Groups[1].Value; + + resultCreated = true; + return result; + } + + #endregion + + #region GetStatus() + + /// + /// Returns the status code.
+ /// Supported status codes are:
+ /// 200 Success
+ /// 510 Invalid or unknown command
+ /// 520 Invalid command syntax
+ ///
+ /// the status code. + public int GetStatus() + { + if (statusCreated) + return status; + matcher = Common.AGI_STATUS_PATTERN.Match(firstLine); + if (matcher.Success) + status = Int32.Parse(matcher.Groups[1].Value); + statusCreated = true; + return status; + } + + #endregion + + #region GetAttribute(name) + + /// + /// Returns an additional attribute contained in the reply.
+ /// For example the reply to the StreamFileCommand contains an additional + /// endpos attribute indicating the frame where the playback was stopped. + /// This can be retrieved by calling getAttribute("endpos") on the corresponding reply. + ///
+ /// the name of the attribute to retrieve. The name is case insensitive. + /// the value of the attribute or null if it is not set. + public string GetAttribute(string name) + { + if (GetStatus() != (int) AGIReplyStatuses.SC_SUCCESS) + return null; + + if ("result".ToUpper().Equals(name.ToUpper())) + return GetResult(); + + if (!attributesCreated) + { + matcher = Common.AGI_ADDITIONAL_ATTRIBUTES_PATTERN.Match(firstLine); + if (matcher.Success) + { + string s; + Match attributeMatcher; + + attributes = new Dictionary(); + s = matcher.Groups[2].Value; + attributeMatcher = Common.AGI_ADDITIONAL_ATTRIBUTE_PATTERN.Match(s); + while (attributeMatcher.Success) + { + string key; + string value_Renamed; + + key = attributeMatcher.Groups[1].Value; + value_Renamed = attributeMatcher.Groups[2].Value; + attributes[key.ToLower(Helper.CultureInfo)] = value_Renamed; + } + } + attributesCreated = true; + } + + if (attributes == null || (attributes.Count == 0)) + return null; + + return attributes[name.ToLower(Helper.CultureInfo)]; + } + + #endregion + + #region GetSynopsis() + + /// + /// Returns the synopsis of the command sent if Asterisk expected a different + /// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). + /// + /// the synopsis of the command sent, null if there were no syntax errors. + public string GetSynopsis() + { + if (GetStatus() != (int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX) + return null; + + if (!synopsisCreated) + { + if (lines.Count > 1) + { + string secondLine; + Match synopsisMatcher; + + secondLine = lines[1]; + synopsisMatcher = Common.AGI_SYNOPSIS_PATTERN.Match(secondLine); + if (synopsisMatcher.Success) + synopsis = synopsisMatcher.Groups[1].Value; + } + synopsisCreated = true; + + var sbUsage = new StringBuilder(); + string line; + for (int i = 2; i < lines.Count; i++) + { + line = lines[i]; + if (line == Common.AGI_END_OF_PROPER_USAGE) + break; + sbUsage.Append(line.Trim()); + sbUsage.Append(" "); + } + usage = sbUsage.ToString().Trim(); + } + return synopsis; + } + + #endregion + + #region GetUsage() + + /// + /// Returns the usage of the command sent if Asterisk expected a different + /// syntax (getStatus() == SC_INVALID_COMMAND_SYNTAX). + /// + /// + /// the usage of the command sent, + /// null if there were no syntax errors. + /// + public string GetUsage() + { + return usage; + } + + #endregion + + #region ToString() + + public override string ToString() + { + return Helper.ToString(this); + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIRequest.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIRequest.cs index 977a8da..9049514 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIRequest.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIRequest.cs @@ -1,534 +1,578 @@ using System; -using System.IO; -using System.Web; -using System.Text; -using System.Text.RegularExpressions; using System.Collections; -using System.Net; using System.Collections.Generic; +using System.Net; +using System.Text.RegularExpressions; +using System.Web; namespace AsterNET.FastAGI { - /// - /// Default implementation of the AGIRequest interface. - /// - public class AGIRequest - { - #region Variables + /// + /// Default implementation of the AGIRequest interface. + /// + public class AGIRequest + { + #region Variables + #if LOGGER - private Logger logger = Logger.Instance(); + private Logger logger = Logger.Instance(); #endif - private string rawCallerId; - private Dictionary request; + private string rawCallerId; + private readonly Dictionary request; - /// A map assigning the values of a parameter (an array of Strings) to the name of the parameter. - private Dictionary> parameterMap; + /// A map assigning the values of a parameter (an array of Strings) to the name of the parameter. + private Dictionary> parameterMap; - private string parameters; - private string script; - private bool callerIdCreated; - private IPAddress localAddress; - private int localPort; - private IPAddress remoteAddress; - private int remotePort; - #endregion + private string parameters; + private string script; + private bool callerIdCreated; - #region Constructor - AGIRequest(ICollection environment) - /// - /// Creates a new AGIRequest. - /// - /// the first lines as received from Asterisk containing the environment. - public AGIRequest(List environment) - { - if (environment == null) - throw new ArgumentException("Environment must not be null."); - request = buildMap(environment); - } - #endregion + #endregion - #region Request - public IDictionary Request - { - get { return request; } - } - #endregion + #region Constructor - AGIRequest(ICollection environment) - #region RequestURL - /// - /// Returns the full URL of the request in the form agi://host[:port][/script]. - /// - public string RequestURL - { - get { return (string) request["request"]; } - } - #endregion + /// + /// Creates a new AGIRequest. + /// + /// the first lines as received from Asterisk containing the environment. + public AGIRequest(List environment) + { + if (environment == null) + throw new ArgumentException("Environment must not be null."); + request = buildMap(environment); + } - #region Channel - /// - /// Returns the name of the channel. - /// - /// the name of the channel. - public string Channel - { - get { return (string) request["channel"]; } - } - #endregion + #endregion - #region UniqueId - /// - /// Returns the unqiue id of the channel. - /// - /// the unqiue id of the channel. - public string UniqueId - { - get { return (string) request["uniqueid"]; } - } - #endregion + #region Request - #region Type - /// - /// Returns the type of the channel, for example "SIP". - /// - /// the type of the channel, for example "SIP". - public string Type - { - get { return (string) request["type"]; } - } - #endregion + public IDictionary Request + { + get { return request; } + } - #region Language - /// - /// Returns the language, for example "en". - /// - public string Language - { - get { return (string) request["language"]; } - } - #endregion + #endregion - #region CallerId - public string CallerId - { - get - { - string callerIdName = (string)(request["calleridname"]); - string callerId = (string)(request["callerid"]); - if (callerIdName != null) - { - if (callerId == null || callerId.ToLower(Helper.CultureInfo) == "unknown") - return null; - return callerId; - } - else // Asterisk 1.0 - return callerId10(); - } - } - #endregion + #region RequestURL - #region CallerIdName - public string CallerIdName - { - get - { - string callerIdName = (string)(request["calleridname"]); - if (callerIdName != null) - { - // Asterisk 1.2 - if (callerIdName.ToLower(Helper.CultureInfo) == "unknown") - return null; - return callerIdName; - } - else // Asterisk 1.0 - return callerIdName10(); - } - } - #endregion + /// + /// Returns the full URL of the request in the form agi://host[:port][/script]. + /// + public string RequestURL + { + get { return request["request"]; } + } - #region Asterisk 1.0 CallerID and CallerIdName - private string callerId10() - { - int lbPosition; - int rbPosition; - - if (!callerIdCreated) - { - rawCallerId = ((string) request["callerid"]); - callerIdCreated = true; - } - - if (rawCallerId == null) - { - return null; - } - - lbPosition = rawCallerId.IndexOf('<'); - rbPosition = rawCallerId.IndexOf('>'); - - if (lbPosition < 0 || rbPosition < 0) - { - return rawCallerId; - } - - return rawCallerId.Substring(lbPosition + 1, (rbPosition) - (lbPosition + 1)); - } + #endregion - private string callerIdName10() - { - int lbPosition; - string callerIdName; - - if (!callerIdCreated) - { - rawCallerId = ((string) request["callerid"]); - callerIdCreated = true; - } - - if (rawCallerId == null) - return null; - - lbPosition = rawCallerId.IndexOf('<'); - - if (lbPosition < 0) - return null; - - callerIdName = rawCallerId.Substring(0, (lbPosition) - (0)).Trim(); - if (callerIdName.StartsWith("\"") && callerIdName.EndsWith("\"")) - callerIdName = callerIdName.Substring(1, (callerIdName.Length - 1) - (1)); - - if (callerIdName.Length == 0) - return null; - else - return callerIdName; - } - #endregion + #region Channel - #region Dnid - public string Dnid - { - get - { - string dnid = (string)(request["dnid"]); - if (dnid == null || dnid.ToLower(Helper.CultureInfo) == "unknown") - return null; - return dnid; - } - } - #endregion + /// + /// Returns the name of the channel. + /// + /// the name of the channel. + public string Channel + { + get { return request["channel"]; } + } - #region Rdnis - public string Rdnis - { - get - { - string rdnis = (string)(request["rdnis"]); - if (rdnis == null || rdnis.ToLower(Helper.CultureInfo) == "unknown") - return null; - return rdnis; - } - } - #endregion + #endregion - #region Context - /// - /// Returns the context in the dial plan from which the AGI script was called. - /// - public string Context - { - get { return (string) request["context"]; } - } - #endregion + #region UniqueId - #region Extension - /// - /// Returns the extension in the dial plan from which the AGI script was called. - /// - public string Extension - { - get { return (string) request["extension"]; } - } - #endregion + /// + /// Returns the unqiue id of the channel. + /// + /// the unqiue id of the channel. + public string UniqueId + { + get { return request["uniqueid"]; } + } - #region Priority - /// - /// Returns the priority in the dial plan from which the AGI script was called. - /// - public string Priority - { - get - { - if (request["priority"] != null) - { - return (string) request["priority"]; - } - return ""; - } + #endregion - } - #endregion + #region Type - #region Enhanced - /// - /// Returns wheather this agi is passed audio (EAGI - Enhanced AGI).
- /// Enhanced AGI is currently not supported on FastAGI.
- /// true if this agi is passed audio, false otherwise. - ///
- public bool Enhanced - { - get - { - if (request["enhanced"] != null && (string)request["enhanced"] == "1.0") - return true; - return false; - } - } - #endregion + /// + /// Returns the type of the channel, for example "SIP". + /// + /// the type of the channel, for example "SIP". + public string Type + { + get { return request["type"]; } + } - #region AccountCode - /// - /// Returns the account code set for the call. - /// - public string AccountCode - { - get - { - return (string) request["accountCode"]; - } + #endregion - } - #endregion + #region Language - #region LocalAddress - public IPAddress LocalAddress - { - get { return localAddress; } - set { this.localAddress = value; } - } - #endregion + /// + /// Returns the language, for example "en". + /// + public string Language + { + get { return request["language"]; } + } - #region LocalPort - public int LocalPort - { - get { return localPort; } - set { this.localPort = value; } - } - #endregion + #endregion - #region RemoteAddress - public IPAddress RemoteAddress - { - get { return remoteAddress; } - set { this.remoteAddress = value; } - } - #endregion + #region CallerId - #region RemotePort - public int RemotePort - { - get { return remotePort; } - set { this.remotePort = value; } - } - #endregion + public string CallerId + { + get + { + string callerIdName = request["calleridname"]; + string callerId = request["callerid"]; + if (callerIdName != null) + { + if (callerId == null || callerId.ToLower(Helper.CultureInfo) == "unknown") + return null; + return callerId; + } + return callerId10(); + } + } - #region Script() - /// - /// Returns the name of the script to execute. - /// - public string Script - { - get - { - if (script != null) - return script; + #endregion - script = ((string)request["network_script"]); - if (script != null) - { - Match scriptMatcher = Common.AGI_SCRIPT_PATTERN.Match(script); - if (scriptMatcher.Success) - { - script = scriptMatcher.Groups[1].Value; - parameters = scriptMatcher.Groups[2].Value; - } - } - return script; - } - } - #endregion + #region CallerIdName - #region CallingAni2 - public int CallingAni2 - { - get - { - if (request["callingani2"] == null) - return -1; - try - { - return Int32.Parse((string)(request["callingani2"])); - } - catch {} - return -1; - } - } - #endregion + public string CallerIdName + { + get + { + string callerIdName = request["calleridname"]; + if (callerIdName != null) + { + // Asterisk 1.2 + if (callerIdName.ToLower(Helper.CultureInfo) == "unknown") + return null; + return callerIdName; + } + return callerIdName10(); + } + } - #region CallingPres - public int CallingPres - { - get - { - if (request["callingpres"] == null) - return -1; - try - { - return Int32.Parse((string)(request["callingpres"])); - } - catch {} - return -1; - } - } - #endregion + #endregion - #region CallingTns - public int CallingTns - { - get - { - if (request["callingtns"] == null) - return -1; - try - { - return Int32.Parse((string)(request["callingtns"])); - } - catch {} - return -1; - } - } - #endregion + #region Asterisk 1.0 CallerID and CallerIdName - #region CallingTon - public int CallingTon - { - get - { - if (request["callington"] == null) - return -1; - try - { - return Int32.Parse((String)(request["callington"])); - } - catch {} - return -1; - } - } - #endregion + private string callerId10() + { + int lbPosition; + int rbPosition; - #region Parameter(string name) - public string Parameter(string name) - { - List values; - values = ParameterValues(name); - if (values == null || values.Count == 0) - return null; - return values[0]; - } - #endregion + if (!callerIdCreated) + { + rawCallerId = request["callerid"]; + callerIdCreated = true; + } - #region ParameterValues(string name) - public List ParameterValues(string name) - { - if (ParameterMap().Count == 0) - return null; - - return parameterMap[name]; - } - #endregion + if (rawCallerId == null) + { + return null; + } - #region ParameterMap() - public Dictionary> ParameterMap() - { - if (parameterMap == null) - parameterMap = parseParameters(this.parameters); - return parameterMap; - } - #endregion + lbPosition = rawCallerId.IndexOf('<'); + rbPosition = rawCallerId.IndexOf('>'); - #region ToString() - public override string ToString() - { - return Helper.ToString(this); - } - #endregion + if (lbPosition < 0 || rbPosition < 0) + { + return rawCallerId; + } - #region buildMap(ICollection lines) - /// - /// Builds a map containing variable names as key (with the "agi_" prefix stripped) and the corresponding values.
- /// Syntactically invalid and empty variables are skipped. - ///
- /// the environment to transform. - /// a map with the variables set corresponding to the given environment. - private Dictionary buildMap(List lines) - { - int colonPosition; - string key; - string value; + return rawCallerId.Substring(lbPosition + 1, (rbPosition) - (lbPosition + 1)); + } - Dictionary map = new Dictionary(lines.Count); - foreach (string line in lines) - { - colonPosition = line.IndexOf(':'); - if (colonPosition < 0 || !line.StartsWith("agi_") || line.Length < colonPosition + 2) - continue; + private string callerIdName10() + { + int lbPosition; + string callerIdName; - key = line.Substring(4, colonPosition - 4).ToLower(Helper.CultureInfo); - value = line.Substring(colonPosition + 2); - if (value.Length != 0) - map.Add(key, value); - } - return map; - } - #endregion + if (!callerIdCreated) + { + rawCallerId = request["callerid"]; + callerIdCreated = true; + } - #region parseParameters(string s) - /// - /// Parses the given parameter string and caches the result. - /// - /// the parameter string to parse - /// a Map made up of parameter names their values - private Dictionary> parseParameters(string parameters) - { - Dictionary> result = new Dictionary>(); - string name; - string val; + if (rawCallerId == null) + return null; - if (string.IsNullOrEmpty(parameters)) - return result; + lbPosition = rawCallerId.IndexOf('<'); - string[] pars = parameters.Split('&'); - if (pars.Length == 0) - return result; + if (lbPosition < 0) + return null; - foreach (string parameter in pars) - { - val = string.Empty; - int i = parameter.IndexOf('='); - if (i > 0) - { - name = HttpUtility.UrlDecode(parameter.Substring(0, i)); - if (parameter.Length > i + 1) - val = HttpUtility.UrlDecode(parameter.Substring(i + 1)); - } - else if (i < 0) - name = HttpUtility.UrlDecode(parameter); - else - continue; + callerIdName = rawCallerId.Substring(0, (lbPosition) - (0)).Trim(); + if (callerIdName.StartsWith("\"") && callerIdName.EndsWith("\"")) + callerIdName = callerIdName.Substring(1, (callerIdName.Length - 1) - (1)); - if (!result.ContainsKey(name)) - result.Add(name, new List()); - result[name].Add(val); - } - return result; - } - #endregion - } + if (callerIdName.Length == 0) + return null; + return callerIdName; + } + + #endregion + + #region Dnid + + public string Dnid + { + get + { + string dnid = request["dnid"]; + if (dnid == null || dnid.ToLower(Helper.CultureInfo) == "unknown") + return null; + return dnid; + } + } + + #endregion + + #region Rdnis + + public string Rdnis + { + get + { + string rdnis = request["rdnis"]; + if (rdnis == null || rdnis.ToLower(Helper.CultureInfo) == "unknown") + return null; + return rdnis; + } + } + + #endregion + + #region Context + + /// + /// Returns the context in the dial plan from which the AGI script was called. + /// + public string Context + { + get { return request["context"]; } + } + + #endregion + + #region Extension + + /// + /// Returns the extension in the dial plan from which the AGI script was called. + /// + public string Extension + { + get { return request["extension"]; } + } + + #endregion + + #region Priority + + /// + /// Returns the priority in the dial plan from which the AGI script was called. + /// + public string Priority + { + get + { + if (request["priority"] != null) + { + return request["priority"]; + } + return ""; + } + } + + #endregion + + #region Enhanced + + /// + /// Returns wheather this agi is passed audio (EAGI - Enhanced AGI).
+ /// Enhanced AGI is currently not supported on FastAGI.
+ /// true if this agi is passed audio, false otherwise. + ///
+ public bool Enhanced + { + get + { + if (request["enhanced"] != null && request["enhanced"] == "1.0") + return true; + return false; + } + } + + #endregion + + #region AccountCode + + /// + /// Returns the account code set for the call. + /// + public string AccountCode + { + get { return request["accountCode"]; } + } + + #endregion + + #region LocalAddress + + public IPAddress LocalAddress { get; set; } + + #endregion + + #region LocalPort + + public int LocalPort { get; set; } + + #endregion + + #region RemoteAddress + + public IPAddress RemoteAddress { get; set; } + + #endregion + + #region RemotePort + + public int RemotePort { get; set; } + + #endregion + + #region Script() + + /// + /// Returns the name of the script to execute. + /// + public string Script + { + get + { + if (script != null) + return script; + + script = request["network_script"]; + if (script != null) + { + Match scriptMatcher = Common.AGI_SCRIPT_PATTERN.Match(script); + if (scriptMatcher.Success) + { + script = scriptMatcher.Groups[1].Value; + parameters = scriptMatcher.Groups[2].Value; + } + } + return script; + } + } + + #endregion + + #region CallingAni2 + + public int CallingAni2 + { + get + { + if (request["callingani2"] == null) + return -1; + try + { + return Int32.Parse(request["callingani2"]); + } + catch + { + } + return -1; + } + } + + #endregion + + #region CallingPres + + public int CallingPres + { + get + { + if (request["callingpres"] == null) + return -1; + try + { + return Int32.Parse(request["callingpres"]); + } + catch + { + } + return -1; + } + } + + #endregion + + #region CallingTns + + public int CallingTns + { + get + { + if (request["callingtns"] == null) + return -1; + try + { + return Int32.Parse(request["callingtns"]); + } + catch + { + } + return -1; + } + } + + #endregion + + #region CallingTon + + public int CallingTon + { + get + { + if (request["callington"] == null) + return -1; + try + { + return Int32.Parse(request["callington"]); + } + catch + { + } + return -1; + } + } + + #endregion + + #region Parameter(string name) + + public string Parameter(string name) + { + List values; + values = ParameterValues(name); + if (values == null || values.Count == 0) + return null; + return values[0]; + } + + #endregion + + #region ParameterValues(string name) + + public List ParameterValues(string name) + { + if (ParameterMap().Count == 0) + return null; + + return parameterMap[name]; + } + + #endregion + + #region ParameterMap() + + public Dictionary> ParameterMap() + { + if (parameterMap == null) + parameterMap = parseParameters(parameters); + return parameterMap; + } + + #endregion + + #region ToString() + + public override string ToString() + { + return Helper.ToString(this); + } + + #endregion + + #region buildMap(ICollection lines) + + /// + /// Builds a map containing variable names as key (with the "agi_" prefix stripped) and the corresponding values.
+ /// Syntactically invalid and empty variables are skipped. + ///
+ /// the environment to transform. + /// a map with the variables set corresponding to the given environment. + private Dictionary buildMap(List lines) + { + int colonPosition; + string key; + string value; + + var map = new Dictionary(lines.Count); + foreach (var line in lines) + { + colonPosition = line.IndexOf(':'); + if (colonPosition < 0 || !line.StartsWith("agi_") || line.Length < colonPosition + 2) + continue; + + key = line.Substring(4, colonPosition - 4).ToLower(Helper.CultureInfo); + value = line.Substring(colonPosition + 2); + if (value.Length != 0) + map.Add(key, value); + } + return map; + } + + #endregion + + #region parseParameters(string s) + + /// + /// Parses the given parameter string and caches the result. + /// + /// the parameter string to parse + /// a Map made up of parameter names their values + private Dictionary> parseParameters(string parameters) + { + var result = new Dictionary>(); + string name; + string val; + + if (string.IsNullOrEmpty(parameters)) + return result; + + string[] pars = parameters.Split('&'); + if (pars.Length == 0) + return result; + + foreach (var parameter in pars) + { + val = string.Empty; + int i = parameter.IndexOf('='); + if (i > 0) + { + name = HttpUtility.UrlDecode(parameter.Substring(0, i)); + if (parameter.Length > i + 1) + val = HttpUtility.UrlDecode(parameter.Substring(i + 1)); + } + else if (i < 0) + name = HttpUtility.UrlDecode(parameter); + else + continue; + + if (!result.ContainsKey(name)) + result.Add(name, new List()); + result[name].Add(val); + } + return result; + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AGIWriter.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AGIWriter.cs index c687509..b502bc8 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AGIWriter.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AGIWriter.cs @@ -1,31 +1,33 @@ -using System; using System.IO; +using AsterNET.FastAGI.Command; +using AsterNET.IO; + namespace AsterNET.FastAGI { - /// - /// Default implementation of the AGIWriter interface. - /// - public class AGIWriter - { - private IO.SocketConnection socket; + /// + /// Default implementation of the AGIWriter interface. + /// + public class AGIWriter + { + private readonly SocketConnection socket; - public AGIWriter(IO.SocketConnection socket) - { - lock (this) - this.socket = socket; - } + public AGIWriter(SocketConnection socket) + { + lock (this) + this.socket = socket; + } - public void SendCommand(Command.AGICommand command) - { - string buffer = command.BuildCommand() + "\n"; - try - { - socket.Write(buffer); - } - catch (IOException e) - { - throw new AGINetworkException("Unable to send command to Asterisk: " + e.Message, e); - } - } - } + public void SendCommand(AGICommand command) + { + string buffer = command.BuildCommand() + "\n"; + try + { + socket.Write(buffer); + } + catch (IOException e) + { + throw new AGINetworkException("Unable to send command to Asterisk: " + e.Message, e); + } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs index 34ca7ff..8e7decf 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/AsteriskFastAGI.cs @@ -1,271 +1,308 @@ -using AsterNET.FastAGI.MappingStrategies; using System.IO; using System.Net; using System.Text; +using AsterNET.FastAGI.MappingStrategies; +using AsterNET.IO; +using AsterNET.Util; namespace AsterNET.FastAGI { - public class AsteriskFastAGI + public class AsteriskFastAGI { - #region Flags + /// - /// If set to true, causes the AGIChannel to throw an exception when a status code of 511 (Channel Dead) is returned. - /// This is set to false by default to maintain backwards compatibility + /// If set to true, causes the AGIChannel to throw an exception when a status code of 511 (Channel Dead) is returned. + /// This is set to false by default to maintain backwards compatibility /// public bool SC511_CAUSES_EXCEPTION = false; /// - /// If set to true, causes the AGIChannel to throw an exception when return status is 0 and reply is HANGUP. - /// This is set to false by default to maintain backwards compatibility + /// If set to true, causes the AGIChannel to throw an exception when return status is 0 and reply is HANGUP. + /// This is set to false by default to maintain backwards compatibility /// public bool SCHANGUP_CAUSES_EXCEPTION = false; + #endregion - + #region Variables + #if LOGGER - private Logger logger = Logger.Instance(); + private readonly Logger logger = Logger.Instance(); #endif - private IO.ServerSocket serverSocket; + private ServerSocket serverSocket; - /// The port to listen on. - private int port; - /// The address to listen on. - private string address; - /// The thread pool that contains the worker threads to process incoming requests. - private Util.ThreadPool pool; - /// The number of worker threads in the thread pool. This equals the maximum number of concurrent requests this AGIServer can serve. - private int poolSize; - /// True while this server is shut down. - private bool stopped; - /// - /// The strategy to use for bind AGIRequests to AGIScripts that serve them. - /// - private IMappingStrategy mappingStrategy; - private Encoding socketEncoding = Encoding.ASCII; - #endregion + /// The port to listen on. + private int port; - #region PoolSize - /// - /// Sets the number of worker threads in the thread pool.
- /// This equals the maximum number of concurrent requests this AGIServer can serve.
- /// The default pool size is 10. - ///
- public int PoolSize - { - set { this.poolSize = value; } - } - #endregion + /// The address to listen on. + private readonly string address; - #region BindPort - /// - /// Sets the TCP port to listen on for new connections.
- /// The default bind port is 4573. - ///
- public int BindPort - { - set - { - this.port = value; - } - } - #endregion + /// The thread pool that contains the worker threads to process incoming requests. + private ThreadPool pool; - #region MappingStrategy - /// - /// Sets the strategy to use for mapping AGIRequests to AGIScripts that serve them.
- /// The default mapping is a MappingStrategy. - ///
- /// - public IMappingStrategy MappingStrategy - { - set { this.mappingStrategy = value; } - } - #endregion + /// + /// The number of worker threads in the thread pool. This equals the maximum number of concurrent requests this + /// AGIServer can serve. + /// + private int poolSize; - #region SocketEncoding - public Encoding SocketEncoding - { - get { return this.socketEncoding; } - set { this.socketEncoding = value; } - } - #endregion + /// True while this server is shut down. + private bool stopped; - #region Constructor - AsteriskFastAGI() - /// - /// Creates a new AsteriskFastAGI. - /// - public AsteriskFastAGI() - { - this.address = Common.AGI_BIND_ADDRESS; - this.port = Common.AGI_BIND_PORT; - this.poolSize = Common.AGI_POOL_SIZE; - this.mappingStrategy = new ResourceMappingStrategy(); - } - #endregion + /// + /// The strategy to use for bind AGIRequests to AGIScripts that serve them. + /// + private IMappingStrategy mappingStrategy; - #region Constructor - AsteriskFastAGI() - /// - /// Creates a new AsteriskFastAGI. - /// - public AsteriskFastAGI(string mappingStrategy) - { - this.address = Common.AGI_BIND_ADDRESS; - this.port = Common.AGI_BIND_PORT; - this.poolSize = Common.AGI_POOL_SIZE; - this.mappingStrategy = new ResourceMappingStrategy(mappingStrategy); - } - #endregion + private Encoding socketEncoding = Encoding.ASCII; + + #endregion + + #region PoolSize + + /// + /// Sets the number of worker threads in the thread pool.
+ /// This equals the maximum number of concurrent requests this AGIServer can serve.
+ /// The default pool size is 10. + ///
+ public int PoolSize + { + set { poolSize = value; } + } + + #endregion + + #region BindPort + + /// + /// Sets the TCP port to listen on for new connections.
+ /// The default bind port is 4573. + ///
+ public int BindPort + { + set { port = value; } + } + + #endregion + + #region MappingStrategy + + /// + /// Sets the strategy to use for mapping AGIRequests to AGIScripts that serve them.
+ /// The default mapping is a MappingStrategy. + ///
+ /// + public IMappingStrategy MappingStrategy + { + set { mappingStrategy = value; } + } + + #endregion + + #region SocketEncoding + + public Encoding SocketEncoding + { + get { return socketEncoding; } + set { socketEncoding = value; } + } + + #endregion #region Constructor - AsteriskFastAGI() + /// - /// Creates a new AsteriskFastAGI. + /// Creates a new AsteriskFastAGI. + /// + public AsteriskFastAGI() + { + address = Common.AGI_BIND_ADDRESS; + port = Common.AGI_BIND_PORT; + poolSize = Common.AGI_POOL_SIZE; + mappingStrategy = new ResourceMappingStrategy(); + } + + #endregion + + #region Constructor - AsteriskFastAGI() + + /// + /// Creates a new AsteriskFastAGI. + /// + public AsteriskFastAGI(string mappingStrategy) + { + address = Common.AGI_BIND_ADDRESS; + port = Common.AGI_BIND_PORT; + poolSize = Common.AGI_POOL_SIZE; + this.mappingStrategy = new ResourceMappingStrategy(mappingStrategy); + } + + #endregion + + #region Constructor - AsteriskFastAGI() + + /// + /// Creates a new AsteriskFastAGI. /// public AsteriskFastAGI(IMappingStrategy mappingStrategy) { - this.address = Common.AGI_BIND_ADDRESS; - this.port = Common.AGI_BIND_PORT; - this.poolSize = Common.AGI_POOL_SIZE; + address = Common.AGI_BIND_ADDRESS; + port = Common.AGI_BIND_PORT; + poolSize = Common.AGI_POOL_SIZE; this.mappingStrategy = mappingStrategy; } public AsteriskFastAGI(IMappingStrategy mappingStrategy, string ipaddress, int port, int poolSize) { - this.address = ipaddress; + address = ipaddress; this.port = port; this.poolSize = poolSize; this.mappingStrategy = mappingStrategy; } + #endregion - #region Constructor - AsteriskFastAGI(int port, int poolSize) - /// - /// Creates a new AsteriskFastAGI. - /// - /// The port to listen on. - /// The number of worker threads in the thread pool. - /// This equals the maximum number of concurrent requests this AGIServer can serve. - public AsteriskFastAGI(int port, int poolSize) - { - this.address = Common.AGI_BIND_ADDRESS; - this.port = port; - this.poolSize = poolSize; - this.mappingStrategy = new ResourceMappingStrategy(); - } - #endregion + #region Constructor - AsteriskFastAGI(int port, int poolSize) - #region Constructor - AsteriskFastAGI(string address, int port, int poolSize) - /// - /// Creates a new AsteriskFastAGI. - /// - /// The address to listen on. - /// The port to listen on. - /// The number of worker threads in the thread pool. - /// This equals the maximum number of concurrent requests this AGIServer can serve. - public AsteriskFastAGI(string ipaddress, int port, int poolSize) - { - this.address = ipaddress; - this.port = port; - this.poolSize = poolSize; - this.mappingStrategy = new ResourceMappingStrategy(); - } - #endregion - - public AsteriskFastAGI(string ipaddress = Common.AGI_BIND_ADDRESS, - int port = Common.AGI_BIND_PORT, - int poolSize = Common.AGI_POOL_SIZE, - bool sc511_CausesException = false, - bool scHangUp_CausesException = false) - { - this.address = ipaddress; - this.port = port; - this.poolSize = poolSize; - this.mappingStrategy = new ResourceMappingStrategy(); - SC511_CAUSES_EXCEPTION = sc511_CausesException; - SCHANGUP_CAUSES_EXCEPTION = scHangUp_CausesException; + /// + /// Creates a new AsteriskFastAGI. + /// + /// The port to listen on. + /// + /// The number of worker threads in the thread pool. + /// This equals the maximum number of concurrent requests this AGIServer can serve. + /// + public AsteriskFastAGI(int port, int poolSize) + { + address = Common.AGI_BIND_ADDRESS; + this.port = port; + this.poolSize = poolSize; + mappingStrategy = new ResourceMappingStrategy(); } - #region Start() - public void Start() - { - stopped = false; - mappingStrategy.Load(); - pool = new Util.ThreadPool("AGIServer", poolSize); + #endregion + + #region Constructor - AsteriskFastAGI(string address, int port, int poolSize) + + /// + /// Creates a new AsteriskFastAGI. + /// + /// The address to listen on. + /// The port to listen on. + /// + /// The number of worker threads in the thread pool. + /// This equals the maximum number of concurrent requests this AGIServer can serve. + /// + public AsteriskFastAGI(string ipaddress, int port, int poolSize) + { + address = ipaddress; + this.port = port; + this.poolSize = poolSize; + mappingStrategy = new ResourceMappingStrategy(); + } + + #endregion + + public AsteriskFastAGI(string ipaddress = Common.AGI_BIND_ADDRESS, + int port = Common.AGI_BIND_PORT, + int poolSize = Common.AGI_POOL_SIZE, + bool sc511_CausesException = false, + bool scHangUp_CausesException = false) + { + address = ipaddress; + this.port = port; + this.poolSize = poolSize; + mappingStrategy = new ResourceMappingStrategy(); + SC511_CAUSES_EXCEPTION = sc511_CausesException; + SCHANGUP_CAUSES_EXCEPTION = scHangUp_CausesException; + } + + #region Start() + + public void Start() + { + stopped = false; + mappingStrategy.Load(); + pool = new ThreadPool("AGIServer", poolSize); #if LOGGER - logger.Info("Thread pool started."); + logger.Info("Thread pool started."); #endif - try - { - IPAddress ipAddress = IPAddress.Parse(address); - serverSocket = new IO.ServerSocket(port, ipAddress, this.SocketEncoding); - } - catch(IOException ex) - { + try + { + var ipAddress = IPAddress.Parse(address); + serverSocket = new ServerSocket(port, ipAddress, SocketEncoding); + } + catch (IOException ex) + { #if LOGGER - logger.Error("Unable start AGI Server: cannot to bind to "+ address + ":" + port + ".", ex); + logger.Error("Unable start AGI Server: cannot to bind to " + address + ":" + port + ".", ex); #endif - throw ex; - } + throw ex; + } #if LOGGER - logger.Info("Listening on "+ address + ":" + port + "."); + logger.Info("Listening on " + address + ":" + port + "."); #endif - AGIConnectionHandler connectionHandler; - IO.SocketConnection socket; - try - { - while ((socket = serverSocket.Accept()) != null) - { + try + { + SocketConnection socket; + while ((socket = serverSocket.Accept()) != null) + { #if LOGGER - logger.Info("Received connection."); + logger.Info("Received connection."); #endif - connectionHandler = new AGIConnectionHandler(socket, mappingStrategy, this.SC511_CAUSES_EXCEPTION, this.SCHANGUP_CAUSES_EXCEPTION); - pool.AddJob(connectionHandler); - } - } - catch (IOException ex) - { - if (!stopped) - { + var connectionHandler = new AGIConnectionHandler(socket, mappingStrategy, SC511_CAUSES_EXCEPTION, + SCHANGUP_CAUSES_EXCEPTION); + pool.AddJob(connectionHandler); + } + } + catch (IOException ex) + { + if (!stopped) + { #if LOGGER - logger.Error("IOException while waiting for connections (1).", ex); + logger.Error("IOException while waiting for connections (1).", ex); #endif - throw ex; - } - } - finally - { - if (serverSocket != null) - { - try - { - serverSocket.Close(); - } + throw ex; + } + } + finally + { + if (serverSocket != null) + { + try + { + serverSocket.Close(); + } #if LOGGER - catch (IOException ex) - { - logger.Error("IOException while waiting for connections (2).", ex); - } + catch (IOException ex) + { + logger.Error("IOException while waiting for connections (2).", ex); + } #else catch { } #endif - } - serverSocket = null; - pool.Shutdown(); + } + serverSocket = null; + pool.Shutdown(); #if LOGGER - logger.Info("AGIServer shut down."); + logger.Info("AGIServer shut down."); #endif - } - } - #endregion + } + } - #region Stop() - public void Stop() - { - stopped = true; - if (serverSocket != null) - serverSocket.Close(); - } - #endregion - } -} + #endregion + + #region Stop() + + public void Stop() + { + stopped = true; + if (serverSocket != null) + serverSocket.Close(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategy.cs b/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategy.cs index 6d6d06d..bcc5080 100644 --- a/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategy.cs +++ b/Asterisk.2013/Asterisk.NET/FastAGI/MappingStrategy.cs @@ -1,129 +1,130 @@ -using System; +using System; using System.Collections; -using System.Resources; using System.Reflection; +using System.Resources; namespace AsterNET.FastAGI { - /// - /// A MappingStrategy that is configured via a resource bundle.
- /// The resource bundle contains the script part of the url as key and the fully - /// qualified class name of the corresponding AGIScript as value.
- /// Example: - ///
-	/// noopcommand = AsterNET.FastAGI.Command.NoopCommand
-	/// 
- /// NoopCommand must implement the AGIScript interface and have a default constructor with no parameters.
- ///
- [Obsolete("This class has been depreciated in favour of MappingStrategies.ResourceMappingStrategy", false)] + /// + /// A MappingStrategy that is configured via a resource bundle.
+ /// The resource bundle contains the script part of the url as key and the fully + /// qualified class name of the corresponding AGIScript as value.
+ /// Example: + ///
+    ///         noopcommand = AsterNET.FastAGI.Command.NoopCommand
+    ///     
+ /// NoopCommand must implement the AGIScript interface and have a default constructor with no parameters.
+ ///
+ [Obsolete("This class has been depreciated in favour of MappingStrategies.ResourceMappingStrategy", false)] public class MappingStrategy : IMappingStrategy - { + { #if LOGGER - private Logger logger = Logger.Instance(); + private readonly Logger logger = Logger.Instance(); #endif - private string resourceName; - private Hashtable mapping; + private string resourceName; + private Hashtable mapping; - public MappingStrategy() - { - this.resourceName = Common.AGI_DEFAULT_RESOURCE_BUNDLE_NAME; - this.mapping = null; - } + public MappingStrategy() + { + resourceName = Common.AGI_DEFAULT_RESOURCE_BUNDLE_NAME; + mapping = null; + } public MappingStrategy(string resourceName) - { - this.resourceName = resourceName; - this.mapping = null; - } + { + this.resourceName = resourceName; + mapping = null; + } - public AGIScript DetermineScript(AGIRequest request) - { - AGIScript script = null; - if (mapping != null) - lock (mapping.SyncRoot) - { - if (mapping.Contains(request.Script)) - script = (AGIScript)mapping[request.Script]; - } - return script; - } + public AGIScript DetermineScript(AGIRequest request) + { + AGIScript script = null; + if (mapping != null) + lock (mapping.SyncRoot) + { + if (mapping.Contains(request.Script)) + script = (AGIScript) mapping[request.Script]; + } + return script; + } - public string ResourceBundleName - { - set - { - if (value == null) - { - mapping = null; - resourceName = null; - } - else if (this.resourceName != value) - { - this.resourceName = value; - Load(); - } - } - } + public string ResourceBundleName + { + set + { + if (value == null) + { + mapping = null; + resourceName = null; + } + else if (resourceName != value) + { + resourceName = value; + Load(); + } + } + } - public void Load() - { - string scriptName; - string className; - AGIScript agiScript; + public void Load() + { + string scriptName; + string className; + AGIScript agiScript; - if (mapping == null) - mapping = new Hashtable(); - lock (mapping) - { - mapping.Clear(); - try - { - ResourceReader rr = new ResourceReader(AppDomain.CurrentDomain.BaseDirectory + resourceName); - foreach (DictionaryEntry de in rr) - { - scriptName = (string)de.Key; - className = (string)de.Value; - agiScript = CreateAGIScriptInstance(className); - if(mapping.Contains(scriptName)) - throw new AGIException(String.Format("Duplicate mapping name '{0}' in file {1}", scriptName, resourceName)); - mapping.Add(scriptName, agiScript); + if (mapping == null) + mapping = new Hashtable(); + lock (mapping) + { + mapping.Clear(); + try + { + var rr = new ResourceReader(AppDomain.CurrentDomain.BaseDirectory + resourceName); + foreach (DictionaryEntry de in rr) + { + scriptName = (string) de.Key; + className = (string) de.Value; + agiScript = CreateAGIScriptInstance(className); + if (mapping.Contains(scriptName)) + throw new AGIException(String.Format("Duplicate mapping name '{0}' in file {1}", scriptName, + resourceName)); + mapping.Add(scriptName, agiScript); #if LOGGER - logger.Info("Added mapping for '" + scriptName + "' to class " + agiScript.GetType().FullName); + logger.Info("Added mapping for '" + scriptName + "' to class " + agiScript.GetType().FullName); #endif - } - } - catch (Exception ex) - { + } + } + catch (Exception ex) + { #if LOGGER - logger.Error("Resource bundle '" + resourceName + "' is missing."); + logger.Error("Resource bundle '" + resourceName + "' is missing."); #endif - throw ex; - } - } - } + throw ex; + } + } + } - private AGIScript CreateAGIScriptInstance(string className) - { - Type agiScriptClass; - ConstructorInfo constructor; - AGIScript agiScript; - - try - { - agiScriptClass = Type.GetType(className); - constructor = agiScriptClass.GetConstructor(new Type[]{}); - agiScript = (AGIScript) constructor.Invoke(new object[]{}); - } - catch(Exception ex) - { + private AGIScript CreateAGIScriptInstance(string className) + { + Type agiScriptClass; + ConstructorInfo constructor; + AGIScript agiScript; + + try + { + agiScriptClass = Type.GetType(className); + constructor = agiScriptClass.GetConstructor(new Type[] {}); + agiScript = (AGIScript) constructor.Invoke(new object[] {}); + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unable to create AGIScript instance of type " + className, ex); - return null; + logger.Error("Unable to create AGIScript instance of type " + className, ex); + return null; #else throw new AGIException("Unable to create AGIScript instance of type " + className, ex); #endif - } - return agiScript; - } - } + } + return agiScript; + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Helper.cs b/Asterisk.2013/Asterisk.NET/Helper.cs index 3dcb263..2b903a5 100644 --- a/Asterisk.2013/Asterisk.NET/Helper.cs +++ b/Asterisk.2013/Asterisk.NET/Helper.cs @@ -1,836 +1,884 @@ using System; -using System.Globalization; -using System.Text; using System.Collections; -using System.Collections.Specialized; -using System.Threading; -using System.Reflection; -using System.Security.Cryptography; using System.Collections.Generic; +using System.Globalization; +using System.Reflection; +using System.Text; +using AsterNET.Manager; using AsterNET.Manager.Event; using AsterNET.Manager.Response; -using AsterNET.Manager; namespace AsterNET { - internal class Helper - { - private static CultureInfo defaultCulture; + internal class Helper + { + private static CultureInfo defaultCulture; #if LOGGER - private static Logger logger = Logger.Instance(); + private static readonly Logger logger = Logger.Instance(); #endif - #region CultureInfo - internal static CultureInfo CultureInfo - { - get - { - if (defaultCulture == null) - defaultCulture = System.Globalization.CultureInfo.GetCultureInfo("en"); - return defaultCulture; - } - } - #endregion + #region CultureInfo - #region ToHexString(sbyte[]) - /// The hex digits used to build a hex string representation of a byte array. - internal static readonly char[] hexChar = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + internal static CultureInfo CultureInfo + { + get + { + if (defaultCulture == null) + defaultCulture = CultureInfo.GetCultureInfo("en"); + return defaultCulture; + } + } - /// - /// Converts a byte array to a hex string representing it. The hex digits are lower case. - /// - /// the byte array to convert - /// the hex representation of b - internal static string ToHexString(sbyte[] b) - { - StringBuilder sb = new StringBuilder(b.Length * 2); - for (int i = 0; i < b.Length; i++) - { - sb.Append(hexChar[Helper.URShift((b[i] & 0xf0), 4)]); - sb.Append(hexChar[b[i] & 0x0f]); - } - return sb.ToString(); - } - #endregion + #endregion - #region GetInternalActionId(actionId) - internal static string GetInternalActionId(string actionId) - { - if (string.IsNullOrEmpty(actionId)) - return string.Empty; - int delimiterIndex = actionId.IndexOf(Common.INTERNAL_ACTION_ID_DELIMITER); - if (delimiterIndex > 0) - return actionId.Substring(0, delimiterIndex).Trim(); - return string.Empty; - } - #endregion + #region ToHexString(sbyte[]) - #region StripInternalActionId(actionId) - internal static string StripInternalActionId(string actionId) - { - if (string.IsNullOrEmpty(actionId)) - return string.Empty; - int delimiterIndex = actionId.IndexOf(Common.INTERNAL_ACTION_ID_DELIMITER); - if (delimiterIndex > 0) - { + /// The hex digits used to build a hex string representation of a byte array. + internal static readonly char[] hexChar = + { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', + 'e', 'f' + }; + + /// + /// Converts a byte array to a hex string representing it. The hex digits are lower case. + /// + /// the byte array to convert + /// the hex representation of b + internal static string ToHexString(sbyte[] b) + { + var sb = new StringBuilder(b.Length*2); + for (int i = 0; i < b.Length; i++) + { + sb.Append(hexChar[URShift((b[i] & 0xf0), 4)]); + sb.Append(hexChar[b[i] & 0x0f]); + } + return sb.ToString(); + } + + #endregion + + #region GetInternalActionId(actionId) + + internal static string GetInternalActionId(string actionId) + { + if (string.IsNullOrEmpty(actionId)) + return string.Empty; + int delimiterIndex = actionId.IndexOf(Common.INTERNAL_ACTION_ID_DELIMITER); + if (delimiterIndex > 0) + return actionId.Substring(0, delimiterIndex).Trim(); + return string.Empty; + } + + #endregion + + #region StripInternalActionId(actionId) + + internal static string StripInternalActionId(string actionId) + { + if (string.IsNullOrEmpty(actionId)) + return string.Empty; + int delimiterIndex = actionId.IndexOf(Common.INTERNAL_ACTION_ID_DELIMITER); + if (delimiterIndex > 0) + { if (actionId.Length > delimiterIndex + 1) return actionId.Substring(delimiterIndex + 1).Trim(); + return actionId.Substring(0, delimiterIndex).Trim(); + } + return string.Empty; + } + + #endregion + + #region IsTrue(string) + + /// + /// Checks if a String represents true or false according to Asterisk's logic.
+ /// The original implementation is util.c is as follows: + ///
+ /// the String to check for true. + /// + /// true if s represents true, + /// false otherwise. + /// + internal static bool IsTrue(string s) + { + if (s == null || s.Length == 0) + return false; + string sx = s.ToLower(CultureInfo); + if (sx == "yes" || sx == "true" || sx == "y" || sx == "t" || sx == "1" || sx == "on") + return true; + return false; + } + + #endregion + + #region URShift(...) + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, int bits) + { + if (number >= 0) + return number >> bits; + return (number >> bits) + (2 << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static int URShift(int number, long bits) + { + return URShift(number, (int) bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, int bits) + { + if (number >= 0) + return number >> bits; + return (number >> bits) + (2L << ~bits); + } + + /// + /// Performs an unsigned bitwise right shift with the specified number + /// + /// Number to operate on + /// Ammount of bits to shift + /// The resulting number from the shift operation + internal static long URShift(long number, long bits) + { + return URShift(number, (int) bits); + } + + #endregion + + #region ToArray(ICollection c, object[] objects) + + /// + /// Obtains an array containing all the elements of the collection. + /// + /// The array into which the elements of the collection will be stored. + /// The array containing all the elements of the collection. + internal static object[] ToArray(ICollection c, object[] objects) + { + int index = 0; + + Type type = objects.GetType().GetElementType(); + var objs = (object[]) Array.CreateInstance(type, c.Count); + + IEnumerator e = c.GetEnumerator(); + + while (e.MoveNext()) + objs[index++] = e.Current; + + //If objects is smaller than c then do not return the new array in the parameter + if (objects.Length >= c.Count) + objs.CopyTo(objects, 0); + + return objs; + } + + #endregion + + #region ParseVariables(Dictionary dictionary, string variables, char[] delim) + + /// + /// Parse variable(s) string to dictionary. + /// + /// + /// variable(a) string + /// variable pairs delimiter + /// + internal static Dictionary ParseVariables(Dictionary dictionary, + string variables, char[] delim) + { + if (dictionary == null) + dictionary = new Dictionary(); + else + dictionary.Clear(); + + if (string.IsNullOrEmpty(variables)) + return dictionary; + string[] vars = variables.Split(delim); + int idx; + string vname, vval; + foreach (var var in vars) + { + idx = var.IndexOf('='); + if (idx > 0) + { + vname = var.Substring(0, idx); + vval = var.Substring(idx + 1); + } else - return actionId.Substring(0, delimiterIndex).Trim(); - } - return string.Empty; - } - #endregion + { + vname = var; + vval = string.Empty; + } + dictionary.Add(vname, vval); + } + return dictionary; + } - #region IsTrue(string) - /// - /// Checks if a String represents true or false according to Asterisk's logic.
- /// The original implementation is util.c is as follows: - ///
- /// the String to check for true. - /// - /// true if s represents true, - /// false otherwise. - /// - internal static bool IsTrue(string s) - { - if (s == null || s.Length == 0) - return false; - string sx = s.ToLower(Helper.CultureInfo); - if (sx == "yes" || sx == "true" || sx == "y" || sx == "t" || sx == "1" || sx == "on") - return true; - return false; - } - #endregion + #endregion - #region URShift(...) - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, int bits) - { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2 << ~bits); - } + #region JoinVariables(IDictionary dictionary, string delim) - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static int URShift(int number, long bits) - { - return URShift(number, (int)bits); - } + /// + /// Join variables dictionary to string. + /// + /// + /// + /// + internal static string JoinVariables(IDictionary dictionary, char[] delim, string delimKeyValue) + { + return JoinVariables(dictionary, new string(delim), delimKeyValue); + } - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, int bits) - { - if (number >= 0) - return number >> bits; - else - return (number >> bits) + (2L << ~bits); - } + internal static string JoinVariables(IDictionary dictionary, string delim, string delimKeyValue) + { + if (dictionary == null) + return string.Empty; + var sb = new StringBuilder(); + foreach (DictionaryEntry var in dictionary) + { + if (sb.Length > 0) + sb.Append(delim); + sb.Append(string.Concat(var.Key, delimKeyValue, var.Value)); + } + return sb.ToString(); + } - /// - /// Performs an unsigned bitwise right shift with the specified number - /// - /// Number to operate on - /// Ammount of bits to shift - /// The resulting number from the shift operation - internal static long URShift(long number, long bits) - { - return URShift(number, (int)bits); - } - #endregion + #endregion - #region ToArray(ICollection c, object[] objects) - /// - /// Obtains an array containing all the elements of the collection. - /// - /// The array into which the elements of the collection will be stored. - /// The array containing all the elements of the collection. - internal static object[] ToArray(ICollection c, object[] objects) - { - int index = 0; + #region GetMillisecondsFrom(DateTime start) - Type type = objects.GetType().GetElementType(); - object[] objs = (object[])Array.CreateInstance(type, c.Count); + internal static long GetMillisecondsFrom(DateTime start) + { + TimeSpan ts = DateTime.Now - start; + return (long) ts.TotalMilliseconds; + } - IEnumerator e = c.GetEnumerator(); + #endregion - while (e.MoveNext()) - objs[index++] = e.Current; + #region ParseString(string val) - //If objects is smaller than c then do not return the new array in the parameter - if (objects.Length >= c.Count) - objs.CopyTo(objects, 0); + internal static object ParseString(string val) + { + if (val == "none") + return string.Empty; + return val; + } - return objs; - } - #endregion + #endregion - #region ParseVariables(Dictionary dictionary, string variables, char[] delim) - /// - /// Parse variable(s) string to dictionary. - /// - /// - /// variable(a) string - /// variable pairs delimiter - /// - internal static Dictionary ParseVariables(Dictionary dictionary, string variables, char[] delim) - { - if (dictionary == null) - dictionary = new Dictionary(); - else - dictionary.Clear(); + #region GetGetters(class) - if (string.IsNullOrEmpty(variables)) - return dictionary; - string[] vars = variables.Split(delim); - int idx; - string vname, vval; - foreach (string var in vars) - { - idx = var.IndexOf('='); - if (idx > 0) - { - vname = var.Substring(0, idx); - vval = var.Substring(idx + 1); - } - else - { - vname = var; - vval = string.Empty; - } - dictionary.Add(vname, vval); - } - return dictionary; - } - #endregion + /// + /// Returns a Map of getter methods of the given class.
+ /// The key of the map contains the name of the attribute that can be accessed by the getter, the + /// value the getter itself . A method is considered a getter if its name starts with "get", + /// it is declared internal and takes no arguments. + ///
+ /// the class to return the getters for + /// a Map of attributes and their accessor methods (getters) + internal static Dictionary GetGetters(Type clazz) + { + string name; + string methodName; + MethodInfo method; - #region JoinVariables(IDictionary dictionary, string delim) - /// - /// Join variables dictionary to string. - /// - /// - /// - /// - internal static string JoinVariables(IDictionary dictionary, char[] delim, string delimKeyValue) - { - return JoinVariables(dictionary, new string(delim), delimKeyValue); - } - internal static string JoinVariables(IDictionary dictionary, string delim, string delimKeyValue) - { - if (dictionary == null) - return string.Empty; - StringBuilder sb = new StringBuilder(); - foreach (DictionaryEntry var in dictionary) - { - if (sb.Length > 0) - sb.Append(delim); - sb.Append(string.Concat(var.Key, delimKeyValue, var.Value)); - } - return sb.ToString(); - } - #endregion + var accessors = new Dictionary(); + MethodInfo[] methods = clazz.GetMethods(); - #region GetMillisecondsFrom(DateTime start) - internal static long GetMillisecondsFrom(DateTime start) - { - TimeSpan ts = (TimeSpan)(DateTime.Now - start); - return (long)ts.TotalMilliseconds; - } - #endregion + for (int i = 0; i < methods.Length; i++) + { + method = methods[i]; + methodName = method.Name; - #region ParseString(string val) - internal static object ParseString(string val) - { - if (val == "none") - return string.Empty; - return val; - } - #endregion + // skip not "get..." methods and skip methods with != 0 parameters + if (!methodName.StartsWith("get_") || method.GetParameters().Length != 0) + continue; - #region GetGetters(class) - /// - /// Returns a Map of getter methods of the given class.
- /// The key of the map contains the name of the attribute that can be accessed by the getter, the - /// value the getter itself . A method is considered a getter if its name starts with "get", - /// it is declared internal and takes no arguments. - ///
- /// the class to return the getters for - /// a Map of attributes and their accessor methods (getters) - internal static Dictionary GetGetters(Type clazz) - { - string name; - string methodName; - MethodInfo method; + name = methodName.Substring(4); + if (name.Length == 0) + continue; + accessors[name] = method; + } + return accessors; + } - Dictionary accessors = new Dictionary(); - MethodInfo[] methods = clazz.GetMethods(); + #endregion - for (int i = 0; i < methods.Length; i++) - { - method = methods[i]; - methodName = method.Name; + #region GetSetters(Type clazz) - // skip not "get..." methods and skip methods with != 0 parameters - if (!methodName.StartsWith("get_") || method.GetParameters().Length != 0) - continue; + /// + /// Returns a Map of setter methods of the given class.
+ /// The key of the map contains the name of the attribute that can be accessed by the setter, the + /// value the setter itself. A method is considered a setter if its name starts with "set", + /// it is declared internal and takes no arguments. + ///
+ /// the class to return the setters for + /// a Map of attributes and their accessor methods (setters) + internal static IDictionary GetSetters(Type clazz) + { + IDictionary accessors = new Hashtable(); + MethodInfo[] methods = clazz.GetMethods(); + string name; + string methodName; + MethodInfo method; - name = methodName.Substring(4); - if (name.Length == 0) - continue; - accessors[name] = method; - } - return accessors; - } - #endregion + for (int i = 0; i < methods.Length; i++) + { + method = methods[i]; + methodName = method.Name; + // skip not "set..." methods and skip methods with != 1 parameters + if (!methodName.StartsWith("set_") || method.GetParameters().Length != 1) + continue; + name = methodName.Substring("set_".Length).ToLower(CultureInfo); + if (name.Length == 0) continue; + accessors[name] = method; + } + return accessors; + } - #region GetSetters(Type clazz) - /// - /// Returns a Map of setter methods of the given class.
- /// The key of the map contains the name of the attribute that can be accessed by the setter, the - /// value the setter itself. A method is considered a setter if its name starts with "set", - /// it is declared internal and takes no arguments. - ///
- /// the class to return the setters for - /// a Map of attributes and their accessor methods (setters) - internal static IDictionary GetSetters(Type clazz) - { - IDictionary accessors = new Hashtable(); - MethodInfo[] methods = clazz.GetMethods(); - string name; - string methodName; - MethodInfo method; + #endregion - for (int i = 0; i < methods.Length; i++) - { - method = methods[i]; - methodName = method.Name; - // skip not "set..." methods and skip methods with != 1 parameters - if (!methodName.StartsWith("set_") || method.GetParameters().Length != 1) - continue; - name = methodName.Substring("set_".Length).ToLower(Helper.CultureInfo); - if (name.Length == 0) continue; - accessors[name] = method; - } - return accessors; - } - #endregion + #region ToString(object obj) - #region ToString(object obj) - /// - /// Convert object with all properties to string - /// - /// - /// - internal static string ToString(object obj) - { - object value; - StringBuilder sb = new StringBuilder(obj.GetType().Name, 1024); - sb.Append(" {"); - string strValue; - IDictionary getters = Helper.GetGetters(obj.GetType()); - bool notFirst = false; - List arrays = new List(); - // First step - all values properties (not a list) - foreach (string name in getters.Keys) - { - MethodInfo getter = (MethodInfo)getters[name]; - Type propType = getter.ReturnType; - if (propType == typeof(object)) - continue; - if (!(propType == typeof(string) || propType == typeof(bool) || propType == typeof(double) || propType == typeof(DateTime) || propType == typeof(int) || propType == typeof(long))) - { - string propTypeName = propType.Name; - if (propTypeName.StartsWith("Dictionary") || propTypeName.StartsWith("List")) - { - arrays.Add(getter); - continue; - } - continue; - } + /// + /// Convert object with all properties to string + /// + /// + /// + internal static string ToString(object obj) + { + object value; + var sb = new StringBuilder(obj.GetType().Name, 1024); + sb.Append(" {"); + string strValue; + IDictionary getters = GetGetters(obj.GetType()); + bool notFirst = false; + var arrays = new List(); + // First step - all values properties (not a list) + foreach (string name in getters.Keys) + { + var getter = (MethodInfo) getters[name]; + Type propType = getter.ReturnType; + if (propType == typeof (object)) + continue; + if ( + !(propType == typeof (string) || propType == typeof (bool) || propType == typeof (double) || + propType == typeof (DateTime) || propType == typeof (int) || propType == typeof (long))) + { + string propTypeName = propType.Name; + if (propTypeName.StartsWith("Dictionary") || propTypeName.StartsWith("List")) + { + arrays.Add(getter); + } + continue; + } - try - { - value = getter.Invoke(obj, new object[] { }); - } - catch - { - continue; - } + try + { + value = getter.Invoke(obj, new object[] {}); + } + catch + { + continue; + } - if (value == null) - continue; - if (value is string) - { - strValue = (string)value; - if (strValue.Length == 0) - continue; - } - else if (value is bool) - { - strValue = ((bool)value ? "true" : "false"); - } - else if (value is double) - { - double d = (double)value; - if (d == 0.0) - continue; - strValue = d.ToString(); - } - else if (value is DateTime) - { - DateTime dt = (DateTime)value; - if (dt == DateTime.MinValue) - continue; - strValue = dt.ToLongTimeString(); - } - else if (value is int) - { - int i = (int)value; - if (i == 0) - continue; - strValue = i.ToString(); - } - else if (value is long) - { - long l = (long)value; - if (l == 0) - continue; - strValue = l.ToString(); - } - else - strValue = value.ToString(); + if (value == null) + continue; + if (value is string) + { + strValue = (string) value; + if (strValue.Length == 0) + continue; + } + else if (value is bool) + { + strValue = ((bool) value ? "true" : "false"); + } + else if (value is double) + { + var d = (double) value; + if (d == 0.0) + continue; + strValue = d.ToString(); + } + else if (value is DateTime) + { + var dt = (DateTime) value; + if (dt == DateTime.MinValue) + continue; + strValue = dt.ToLongTimeString(); + } + else if (value is int) + { + var i = (int) value; + if (i == 0) + continue; + strValue = i.ToString(); + } + else if (value is long) + { + var l = (long) value; + if (l == 0) + continue; + strValue = l.ToString(); + } + else + strValue = value.ToString(); - if (notFirst) - sb.Append("; "); - notFirst = true; - sb.Append(string.Concat(getter.Name.Substring(4), ":", strValue)); - } + if (notFirst) + sb.Append("; "); + notFirst = true; + sb.Append(string.Concat(getter.Name.Substring(4), ":", strValue)); + } - // Second step - all lists - foreach (MethodInfo getter in arrays) - { - value = null; - try - { - value = getter.Invoke(obj, new object[] { }); - } - catch - { - continue; - } - if (value == null) - continue; + // Second step - all lists + foreach (var getter in arrays) + { + value = null; + try + { + value = getter.Invoke(obj, new object[] {}); + } + catch + { + continue; + } + if (value == null) + continue; - #region List - IList list; - if (value is IList && (list = (IList)value).Count > 0) - { - if (notFirst) - sb.Append("; "); - notFirst = true; - sb.Append(getter.Name.Substring(4)); - sb.Append(":["); - bool notFirst2 = false; - foreach (object o in list) - { - if (notFirst2) - sb.Append("; "); - notFirst2 = true; - sb.Append(o.ToString()); - } - sb.Append("]"); - continue; - } - #endregion + #region List - #region IDictionary - else if (value is IDictionary && ((IDictionary)value).Count > 0) - { - if (notFirst) - sb.Append("; "); - notFirst = true; - sb.Append(getter.Name.Substring(4)); - sb.Append(":["); - bool notFirst2 = false; - foreach (object key in ((IDictionary)value).Keys) - { - object o = ((IDictionary)value)[key]; - if (notFirst2) - sb.Append("; "); - notFirst2 = true; - sb.Append(string.Concat(key, ":", o)); - } - sb.Append("]"); - continue; - } - #endregion - } + IList list; + if (value is IList && (list = (IList) value).Count > 0) + { + if (notFirst) + sb.Append("; "); + notFirst = true; + sb.Append(getter.Name.Substring(4)); + sb.Append(":["); + bool notFirst2 = false; + foreach (var o in list) + { + if (notFirst2) + sb.Append("; "); + notFirst2 = true; + sb.Append(o); + } + sb.Append("]"); + } + #endregion - sb.Append("}"); - return sb.ToString(); - } - #endregion + #region IDictionary + if (value is IDictionary && ((IDictionary) value).Count > 0) + { + if (notFirst) + sb.Append("; "); + notFirst = true; + sb.Append(getter.Name.Substring(4)); + sb.Append(":["); + bool notFirst2 = false; + foreach (var key in ((IDictionary) value).Keys) + { + object o = ((IDictionary) value)[key]; + if (notFirst2) + sb.Append("; "); + notFirst2 = true; + sb.Append(string.Concat(key, ":", o)); + } + sb.Append("]"); + } - #region SetAttributes(object evt, IDictionary attributes) - internal static void SetAttributes(IParseSupport o, Dictionary attributes) - { - Type dataType; - object val; + #endregion + } - // Preparse attributes - attributes = o.ParseSpecial(attributes); + sb.Append("}"); + return sb.ToString(); + } - IDictionary setters = Helper.GetSetters(o.GetType()); - MethodInfo setter; - foreach (string name in attributes.Keys) - { - if (name == "event") - continue; + #endregion - if (name == "source") - setter = (MethodInfo)setters["src"]; - else - setter = (MethodInfo)setters[stripIllegalCharacters(name)]; + #region SetAttributes(object evt, IDictionary attributes) - if (setter == null) - { - // No setter found to key, try general parser - if (!o.Parse(name, (string)attributes[name])) - { + internal static void SetAttributes(IParseSupport o, Dictionary attributes) + { + Type dataType; + object val; + + // Preparse attributes + attributes = o.ParseSpecial(attributes); + + IDictionary setters = GetSetters(o.GetType()); + MethodInfo setter; + foreach (var name in attributes.Keys) + { + if (name == "event") + continue; + + if (name == "source") + setter = (MethodInfo) setters["src"]; + else + setter = (MethodInfo) setters[stripIllegalCharacters(name)]; + + if (setter == null) + { + // No setter found to key, try general parser + if (!o.Parse(name, attributes[name])) + { #if LOGGER - logger.Error("Unable to set property '" + name + "' on " + o.GetType() + ": no setter"); + logger.Error("Unable to set property '" + name + "' on " + o.GetType() + ": no setter"); #endif - throw new ManagerException("Parse error key '" + name + "' on " + o.GetType()); - } - } - else - { - dataType = (setter.GetParameters()[0]).ParameterType; - if (dataType == typeof(bool)) - val = Helper.IsTrue((string)attributes[name]); - else if (dataType == typeof(string)) - val = Helper.ParseString((string)attributes[name]); - else if (dataType == typeof(Int32)) - { - Int32 v = 0; - Int32.TryParse((string)attributes[name], out v); - val = v; - } - else if (dataType == typeof(Int64)) - { - Int64 v = 0; - Int64.TryParse((string)attributes[name], out v); - val = v; - } - else if (dataType == typeof(double)) - { - Double v = 0.0; - Double.TryParse((string)attributes[name], System.Globalization.NumberStyles.AllowDecimalPoint, Common.CultureInfoEn, out v); - val = v; - } - else if (dataType == typeof(decimal)) - { - Decimal v = 0; - Decimal.TryParse((string)attributes[name], System.Globalization.NumberStyles.AllowDecimalPoint, Common.CultureInfoEn, out v); - val = v; - } - else if (dataType.IsEnum) - { - try - { - val = Convert.ChangeType(Enum.Parse(dataType, (string)attributes[name], true), dataType); - } - catch (Exception ex) - { + throw new ManagerException("Parse error key '" + name + "' on " + o.GetType()); + } + } + else + { + dataType = (setter.GetParameters()[0]).ParameterType; + if (dataType == typeof (bool)) + val = IsTrue(attributes[name]); + else if (dataType == typeof (string)) + val = ParseString(attributes[name]); + else if (dataType == typeof (Int32)) + { + Int32 v = 0; + Int32.TryParse(attributes[name], out v); + val = v; + } + else if (dataType == typeof (Int64)) + { + Int64 v = 0; + Int64.TryParse(attributes[name], out v); + val = v; + } + else if (dataType == typeof (double)) + { + Double v = 0.0; + Double.TryParse(attributes[name], NumberStyles.AllowDecimalPoint, Common.CultureInfoEn, out v); + val = v; + } + else if (dataType == typeof (decimal)) + { + Decimal v = 0; + Decimal.TryParse(attributes[name], NumberStyles.AllowDecimalPoint, Common.CultureInfoEn, out v); + val = v; + } + else if (dataType.IsEnum) + { + try + { + val = Convert.ChangeType(Enum.Parse(dataType, attributes[name], true), dataType); + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + o.GetType() + " to required enum type " + dataType, ex); - continue; + logger.Error( + "Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + + o.GetType() + " to required enum type " + dataType, ex); + continue; #else throw new ManagerException("Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + o.GetType() + " to required enum type " + dataType, ex); #endif - } - } - else - { - try - { - ConstructorInfo constructor = dataType.GetConstructor(new Type[] { typeof(string) }); - val = constructor.Invoke(new object[] { attributes[name] }); - } - catch (Exception ex) - { + } + } + else + { + try + { + ConstructorInfo constructor = dataType.GetConstructor(new[] {typeof (string)}); + val = constructor.Invoke(new object[] {attributes[name]}); + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + o.GetType() + " to required type " + dataType, ex); - continue; + logger.Error( + "Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + + o.GetType() + " to required type " + dataType, ex); + continue; #else throw new ManagerException("Unable to convert value '" + attributes[name] + "' of property '" + name + "' on " + o.GetType() + " to required type " + dataType, ex); #endif - } - } + } + } - try - { - setter.Invoke(o, new object[] { val }); - } - catch (Exception ex) - { + try + { + setter.Invoke(o, new[] {val}); + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unable to set property '" + name + "' on " + o.GetType(), ex); - continue; + logger.Error("Unable to set property '" + name + "' on " + o.GetType(), ex); #else throw new ManagerException("Unable to set property '" + name + "' on " + o.GetType(), ex); #endif - } - } - } - } - #endregion + } + } + } + } - #region AddKeyValue(IDictionary list, string line) - internal static void AddKeyValue(IDictionary list, string line) - { - int delimiterIndex = line.IndexOf(":"); - if (delimiterIndex > 0 && line.Length > delimiterIndex + 1) - { - string name = line.Substring(0, delimiterIndex).ToLower(Helper.CultureInfo).Trim(); - string val = line.Substring(delimiterIndex + 1).Trim(); - if (val == "") - list[name] = null; - else - list[name] = val; - } - } - #endregion + #endregion - #region stripIllegalCharacters(string s) - /// - /// Strips all illegal charaters from the given lower case string. - /// - /// the original string - /// the string with all illegal characters stripped - private static string stripIllegalCharacters(string s) - { - char c; - bool needsStrip = false; + #region AddKeyValue(IDictionary list, string line) - if (string.IsNullOrEmpty(s)) - return null; + internal static void AddKeyValue(IDictionary list, string line) + { + int delimiterIndex = line.IndexOf(":"); + if (delimiterIndex > 0 && line.Length > delimiterIndex + 1) + { + string name = line.Substring(0, delimiterIndex).ToLower(CultureInfo).Trim(); + string val = line.Substring(delimiterIndex + 1).Trim(); + if (val == "") + list[name] = null; + else + list[name] = val; + } + } - for (int i = 0; i < s.Length; i++) - { - c = s[i]; - if (c >= '0' && c <= '9') - continue; - else if (c >= 'a' && c <= 'z') - continue; - else if (c >= 'A' && c <= 'Z') - continue; - else - { - needsStrip = true; - break; - } - } + #endregion - if (!needsStrip) - return s; + #region stripIllegalCharacters(string s) - StringBuilder sb = new StringBuilder(s.Length); - for (int i = 0; i < s.Length; i++) - { - c = s[i]; - if (c >= '0' && c <= '9') - sb.Append(c); - else if (c >= 'a' && c <= 'z') - sb.Append(c); - else if (c >= 'A' && c <= 'Z') - sb.Append(c); - } + /// + /// Strips all illegal charaters from the given lower case string. + /// + /// the original string + /// the string with all illegal characters stripped + private static string stripIllegalCharacters(string s) + { + char c; + bool needsStrip = false; - return sb.ToString(); - } - #endregion + if (string.IsNullOrEmpty(s)) + return null; - #region BuildResponse(IDictionary attributes) - /// - /// Constructs an instance of ManagerResponse based on a map of attributes. - /// - /// the attributes and their values. The keys of this map must be all lower case. - /// the response with the given attributes. - internal static ManagerResponse BuildResponse(Dictionary attributes) - { - ManagerResponse response; + for (int i = 0; i < s.Length; i++) + { + c = s[i]; + if (c >= '0' && c <= '9') + continue; + if (c >= 'a' && c <= 'z') + continue; + if (c >= 'A' && c <= 'Z') + continue; + needsStrip = true; + break; + } - string responseType = ((string)attributes["response"]).ToLower(Helper.CultureInfo); + if (!needsStrip) + return s; - // Determine type - if (responseType == "error") - response = new ManagerError(); - else if (attributes.ContainsKey("challenge")) - response = new ChallengeResponse(); - else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("waiting")) - response = new MailboxStatusResponse(); - else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("newmessages") && attributes.ContainsKey("oldmessages")) - response = new MailboxCountResponse(); - else if (attributes.ContainsKey("exten") && attributes.ContainsKey("context") && attributes.ContainsKey("hint") && attributes.ContainsKey("status")) - response = new ExtensionStateResponse(); - else - response = new ManagerResponse(); + var sb = new StringBuilder(s.Length); + for (int i = 0; i < s.Length; i++) + { + c = s[i]; + if (c >= '0' && c <= '9') + sb.Append(c); + else if (c >= 'a' && c <= 'z') + sb.Append(c); + else if (c >= 'A' && c <= 'Z') + sb.Append(c); + } - Helper.SetAttributes(response, attributes); - return response; - } - #endregion + return sb.ToString(); + } - #region BuildEvent(Hashtable list, object source, IDictionary attributes) - /// - /// Builds the event based on the given map of attributes and the registered event classes. - /// - /// source attribute for the event - /// map containing event attributes - /// a concrete instance of ManagerEvent or null if no event class was registered for the event type. - internal static ManagerEvent BuildEvent(IDictionary list, ManagerConnection source, Dictionary attributes) - { - ManagerEvent e; - string eventType; - ConstructorInfo constructor = null; - int hash, hashEvent; + #endregion - eventType = ((string)attributes["event"]).ToLower(Helper.CultureInfo); - // Remove Event tail from event name (ex. JabberEvent) - if (eventType.EndsWith("event")) - eventType = eventType.Substring(0, eventType.Length - 5); - hashEvent = eventType.GetHashCode(); + #region BuildResponse(IDictionary attributes) - if (eventType == "user") - { - string userevent = ((string)attributes["userevent"]).ToLower(Helper.CultureInfo); - hash = string.Concat(eventType, userevent).GetHashCode(); - if(list.ContainsKey(hash)) - constructor = list[hash]; - else - constructor = list[hashEvent]; - } - else if (list.ContainsKey(hashEvent)) - constructor = list[hashEvent]; + /// + /// Constructs an instance of ManagerResponse based on a map of attributes. + /// + /// the attributes and their values. The keys of this map must be all lower case. + /// the response with the given attributes. + internal static ManagerResponse BuildResponse(Dictionary attributes) + { + ManagerResponse response; - if (constructor == null) - e = new UnknownEvent(source); - else - { - try - { - e = (ManagerEvent)constructor.Invoke(new object[] { source }); - } - catch (Exception ex) - { + string responseType = attributes["response"].ToLower(CultureInfo); + + // Determine type + if (responseType == "error") + response = new ManagerError(); + else if (attributes.ContainsKey("challenge")) + response = new ChallengeResponse(); + else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("waiting")) + response = new MailboxStatusResponse(); + else if (attributes.ContainsKey("mailbox") && attributes.ContainsKey("newmessages") && + attributes.ContainsKey("oldmessages")) + response = new MailboxCountResponse(); + else if (attributes.ContainsKey("exten") && attributes.ContainsKey("context") && + attributes.ContainsKey("hint") && attributes.ContainsKey("status")) + response = new ExtensionStateResponse(); + else + response = new ManagerResponse(); + + SetAttributes(response, attributes); + return response; + } + + #endregion + + #region BuildEvent(Hashtable list, object source, IDictionary attributes) + + /// + /// Builds the event based on the given map of attributes and the registered event classes. + /// + /// source attribute for the event + /// map containing event attributes + /// a concrete instance of ManagerEvent or null if no event class was registered for the event type. + internal static ManagerEvent BuildEvent(IDictionary list, ManagerConnection source, + Dictionary attributes) + { + ManagerEvent e; + string eventType; + ConstructorInfo constructor = null; + int hash, hashEvent; + + eventType = attributes["event"].ToLower(CultureInfo); + // Remove Event tail from event name (ex. JabberEvent) + if (eventType.EndsWith("event")) + eventType = eventType.Substring(0, eventType.Length - 5); + hashEvent = eventType.GetHashCode(); + + if (eventType == "user") + { + string userevent = attributes["userevent"].ToLower(CultureInfo); + hash = string.Concat(eventType, userevent).GetHashCode(); + if (list.ContainsKey(hash)) + constructor = list[hash]; + else + constructor = list[hashEvent]; + } + else if (list.ContainsKey(hashEvent)) + constructor = list[hashEvent]; + + if (constructor == null) + e = new UnknownEvent(source); + else + { + try + { + e = (ManagerEvent) constructor.Invoke(new object[] {source}); + } + catch (Exception ex) + { #if LOGGER - logger.Error("Unable to create new instance of " + eventType, ex); - return null; + logger.Error("Unable to create new instance of " + eventType, ex); + return null; #else throw ex; #endif - } - } + } + } - SetAttributes(e, attributes); + SetAttributes(e, attributes); - // ResponseEvents are sent in response to a ManagerAction if the - // response contains lots of data. They include the actionId of - // the corresponding ManagerAction. - if (e is ResponseEvent) - { - ResponseEvent responseEvent = (ResponseEvent)e; - string actionId = responseEvent.ActionId; - if (actionId != null) - { - responseEvent.ActionId = Helper.StripInternalActionId(actionId); - responseEvent.InternalActionId = Helper.GetInternalActionId(actionId); - } - } + // ResponseEvents are sent in response to a ManagerAction if the + // response contains lots of data. They include the actionId of + // the corresponding ManagerAction. + if (e is ResponseEvent) + { + var responseEvent = (ResponseEvent) e; + string actionId = responseEvent.ActionId; + if (actionId != null) + { + responseEvent.ActionId = StripInternalActionId(actionId); + responseEvent.InternalActionId = GetInternalActionId(actionId); + } + } - return e; - } - #endregion + return e; + } - #region RegisterBuiltinEventClasses(Hashtable list) - /// - /// Register buildin Event classes - /// - /// - internal static void RegisterBuiltinEventClasses(Dictionary list) - { - Assembly assembly = Assembly.GetExecutingAssembly(); - Type manager = typeof(ManagerEvent); - foreach (Type type in assembly.GetTypes()) - if (type.IsPublic && !type.IsAbstract && manager.IsAssignableFrom(type)) - RegisterEventClass(list, type); - } - #endregion + #endregion - #region RegisterEventClass(Dictionary list, Type clazz) - internal static void RegisterEventClass(Dictionary list, Type clazz) - { - // Ignore all abstract classes - // Class not derived from ManagerEvent - if (clazz.IsAbstract || !typeof(ManagerEvent).IsAssignableFrom(clazz)) - return; + #region RegisterBuiltinEventClasses(Hashtable list) - string eventType = clazz.Name.ToLower(Helper.CultureInfo); + /// + /// Register buildin Event classes + /// + /// + internal static void RegisterBuiltinEventClasses(Dictionary list) + { + Assembly assembly = Assembly.GetExecutingAssembly(); + Type manager = typeof (ManagerEvent); + foreach (var type in assembly.GetTypes()) + if (type.IsPublic && !type.IsAbstract && manager.IsAssignableFrom(type)) + RegisterEventClass(list, type); + } - // Remove "event" at the end (if presents) - if (eventType.EndsWith("event")) - eventType = eventType.Substring(0, eventType.Length - 5); + #endregion - // If assignable from UserEvent and no "userevent" at the start - add "userevent" to beginning - if (typeof(UserEvent).IsAssignableFrom(clazz) && !eventType.StartsWith("user")) - eventType = "user" + eventType; + #region RegisterEventClass(Dictionary list, Type clazz) - int hash = eventType.GetHashCode(); - if (list.ContainsKey(hash)) - return; + internal static void RegisterEventClass(Dictionary list, Type clazz) + { + // Ignore all abstract classes + // Class not derived from ManagerEvent + if (clazz.IsAbstract || !typeof (ManagerEvent).IsAssignableFrom(clazz)) + return; - ConstructorInfo constructor = null; - try - { - constructor = clazz.GetConstructor(new Type[] { typeof(ManagerConnection) }); - } - catch (MethodAccessException ex) - { - throw new ArgumentException("RegisterEventClass : " + clazz + " has no usable constructor.", ex); - } + string eventType = clazz.Name.ToLower(CultureInfo); - if (constructor != null && constructor.IsPublic) - list.Add(hash, constructor); - else - throw new ArgumentException("RegisterEventClass : " + clazz + " has no public default constructor"); - } - #endregion + // Remove "event" at the end (if presents) + if (eventType.EndsWith("event")) + eventType = eventType.Substring(0, eventType.Length - 5); - #region RegisterEventHandler(Dictionary list, int index, Type eventType) - internal static void RegisterEventHandler(Dictionary list, int index, Type eventType) - { - int eventHash = eventType.Name.GetHashCode(); - if (list.ContainsKey(eventHash)) - throw new ArgumentException("Event class already registered : " + eventType.Name); - list.Add(eventHash, index); - } - #endregion - } + // If assignable from UserEvent and no "userevent" at the start - add "userevent" to beginning + if (typeof (UserEvent).IsAssignableFrom(clazz) && !eventType.StartsWith("user")) + eventType = "user" + eventType; + + int hash = eventType.GetHashCode(); + if (list.ContainsKey(hash)) + return; + + ConstructorInfo constructor = null; + try + { + constructor = clazz.GetConstructor(new[] {typeof (ManagerConnection)}); + } + catch (MethodAccessException ex) + { + throw new ArgumentException("RegisterEventClass : " + clazz + " has no usable constructor.", ex); + } + + if (constructor != null && constructor.IsPublic) + list.Add(hash, constructor); + else + throw new ArgumentException("RegisterEventClass : " + clazz + " has no public default constructor"); + } + + #endregion + + #region RegisterEventHandler(Dictionary list, int index, Type eventType) + + internal static void RegisterEventHandler(Dictionary list, int index, Type eventType) + { + int eventHash = eventType.Name.GetHashCode(); + if (list.ContainsKey(eventHash)) + throw new ArgumentException("Event class already registered : " + eventType.Name); + list.Add(eventHash, index); + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/IParseSupport.cs b/Asterisk.2013/Asterisk.NET/IParseSupport.cs index 4b04448..786f849 100644 --- a/Asterisk.2013/Asterisk.NET/IParseSupport.cs +++ b/Asterisk.2013/Asterisk.NET/IParseSupport.cs @@ -1,16 +1,11 @@ -using System; using System.Collections.Generic; -using System.Text; namespace AsterNET { - internal interface IParseSupport - { - Dictionary Attributes - { - get; - } - bool Parse(string key, string value); - Dictionary ParseSpecial(Dictionary attributes); - } -} + internal interface IParseSupport + { + Dictionary Attributes { get; } + bool Parse(string key, string value); + Dictionary ParseSpecial(Dictionary attributes); + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Logger.cs b/Asterisk.2013/Asterisk.NET/Logger.cs index ab09cbe..b515cd9 100644 --- a/Asterisk.2013/Asterisk.NET/Logger.cs +++ b/Asterisk.2013/Asterisk.NET/Logger.cs @@ -1,261 +1,284 @@ using System; -using System.Diagnostics; -using System.Threading; -using System.Text; using System.Collections; +using System.Diagnostics; +using System.Reflection; +using System.Threading; namespace AsterNET { #if LOGGER - #region class LogFactory - /// - /// Facade to hide details of the underlying logging system. - /// - public sealed class Logger - { - private static Logger logger; + #region class LogFactory - /// - /// Returns an instance of Log suitable for logging from the given class. - /// - /// the created logger. - public static Logger Instance() - { - if(logger == null) - logger = new Logger(); - return logger; - } + /// + /// Facade to hide details of the underlying logging system. + /// + public sealed class Logger + { + public enum MessageLevel + { + Info, + Warning, + Error, + Debug + } - public enum MessageLevel - { - Info, - Warning, - Error, - Debug - } - - /// - /// Creates a new CommonsLoggingLog obtained from commons-logging's LogFactory for the given class. - /// - public Logger() - { - } - - private void writeLine(string type, string msg) - { - System.Diagnostics.Debug.Print(string.Format("{0}[{1}] {2}", type, Thread.CurrentThread.Name, msg)); - } - private void writeLine(string msg) - { - System.Diagnostics.Debug.Print(msg); - } - - // Max 2 calls from original caller ! - private string debugInfo() - { - System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(2, true); - System.Reflection.MethodBase mb = sf.GetMethod(); - return string.Concat(mb.DeclaringType.Name, ":", mb.Name); - } + private static Logger logger; - Hashtable visibleDebug = new Hashtable(); - Hashtable visibleError = new Hashtable(); - Hashtable visibleInfo = new Hashtable(); - Hashtable visibleWarning = new Hashtable(); + private Hashtable visibleDebug = new Hashtable(); - private bool visibleDebugDef = true; - private bool visibleErrorDef = true; - private bool visibleInfoDef = true; - private bool visibleWarningDef = true; + private bool visibleDebugDef = true; + private Hashtable visibleError = new Hashtable(); + private bool visibleErrorDef = true; + private Hashtable visibleInfo = new Hashtable(); + private bool visibleInfoDef = true; + private Hashtable visibleWarning = new Hashtable(); + private bool visibleWarningDef = true; - /// - /// Get visibility for message level of class:method - /// - /// messageType:class:method - /// - public bool IsVisible(MessageLevel messageLevel, string classMethod) - { - return isVisible(messageLevel, classMethod.GetHashCode()); - } + /// + /// Creates a new CommonsLoggingLog obtained from commons-logging's LogFactory for the given class. + /// + public Logger() + { + } - private bool isVisible(MessageLevel messageLevel, int hash) - { - switch (messageLevel) - { - case MessageLevel.Debug: - return (visibleDebug.ContainsKey(hash) ? (bool)visibleDebug[hash] : visibleDebugDef); - case MessageLevel.Error: - return (visibleError.ContainsKey(hash) ? (bool)visibleError[hash] : visibleErrorDef); - case MessageLevel.Info: - return (visibleInfo.ContainsKey(hash) ? (bool)visibleInfo[hash] : visibleInfoDef); - case MessageLevel.Warning: - return (visibleWarning.ContainsKey(hash) ? (bool)visibleWarning[hash] : visibleWarningDef); - } - return true; - } + /// + /// Returns an instance of Log suitable for logging from the given class. + /// + /// the created logger. + public static Logger Instance() + { + if (logger == null) + logger = new Logger(); + return logger; + } - /// - /// Set visibility for message level of class:method - /// - /// visible - /// message level - /// class:method - public void Visible(bool visible, MessageLevel messageLevel, string classMethod) - { - int hash = classMethod.GetHashCode(); - switch (messageLevel) - { - case MessageLevel.Debug: - visibleDebug[hash] = visible; - return; - case MessageLevel.Error: - visibleError[hash] = visible; - return; - case MessageLevel.Info: - visibleInfo[hash] = visible; - return; - case MessageLevel.Warning: - visibleWarning[hash] = visible; - return; - } - } + private void writeLine(string type, string msg) + { + System.Diagnostics.Debug.Print("{0}[{1}] {2}", type, Thread.CurrentThread.Name, msg); + } - /// - /// Set visibility for message level of class:method - /// - /// visible - /// message level - /// class:method - public void Visible(bool visible, MessageLevel messageLevel) - { - switch (messageLevel) - { - case MessageLevel.Debug: - visibleDebugDef = visible; - return; - case MessageLevel.Error: - visibleErrorDef = visible; - return; - case MessageLevel.Info: - visibleInfoDef = visible; - return; - case MessageLevel.Warning: - visibleWarningDef = visible; - return; - } - } + private void writeLine(string msg) + { + System.Diagnostics.Debug.Print(msg); + } - #region Debug - public void Debug(object o) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Debug, caller.GetHashCode())) - writeLine(" Debug:", string.Concat(caller, " - ", o.ToString())); - } - public void Debug(string msg) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Debug, caller.GetHashCode())) - writeLine(" Debug:", string.Concat(caller, " - ", msg)); - } - public void Debug(string format, params object[] args) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Debug, caller.GetHashCode())) - writeLine(" Debug:", string.Concat(caller, " - ", string.Format(format, args))); - } - public void Debug(string msg, Exception ex) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Debug, caller.GetHashCode())) - writeLine(" Debug:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); - } - #endregion + // Max 2 calls from original caller ! + private string debugInfo() + { + var sf = new StackFrame(2, true); + MethodBase mb = sf.GetMethod(); + return string.Concat(mb.DeclaringType.Name, ":", mb.Name); + } - #region Info - public void Info(object o) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Info, caller.GetHashCode())) - writeLine(" Info:", string.Concat(caller, " - ", o.ToString())); - } - public void Info(string msg) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Info, caller.GetHashCode())) - writeLine(" Info:", string.Concat(caller, " - ", msg)); - } - public void Info(string format, params object[] args) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Info, caller.GetHashCode())) - writeLine(" Info:", string.Concat(caller, " - ", string.Format(format, args))); - } - public void Info(string msg, Exception ex) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Info, caller.GetHashCode())) - writeLine(" Info:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); - } - #endregion + /// + /// Get visibility for message level of class:method + /// + /// messageType:class:method + /// + public bool IsVisible(MessageLevel messageLevel, string classMethod) + { + return isVisible(messageLevel, classMethod.GetHashCode()); + } - #region Warning - public void Warning(object o) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Warning, caller.GetHashCode())) - writeLine("Warning:", string.Concat(caller, " - ", o.ToString())); - } - public void Warning(string msg) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Warning, caller.GetHashCode())) - writeLine("Warning:", string.Concat(caller, " - ", msg)); - } - public void Warning(string format, params object[] args) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Warning, caller.GetHashCode())) - writeLine("Warning:", string.Concat(caller, " - ", string.Format(format, args))); - } - public void Warning(string msg, Exception ex) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Warning, caller.GetHashCode())) - writeLine("Warning:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); - } - #endregion + private bool isVisible(MessageLevel messageLevel, int hash) + { + switch (messageLevel) + { + case MessageLevel.Debug: + return (visibleDebug.ContainsKey(hash) ? (bool) visibleDebug[hash] : visibleDebugDef); + case MessageLevel.Error: + return (visibleError.ContainsKey(hash) ? (bool) visibleError[hash] : visibleErrorDef); + case MessageLevel.Info: + return (visibleInfo.ContainsKey(hash) ? (bool) visibleInfo[hash] : visibleInfoDef); + case MessageLevel.Warning: + return (visibleWarning.ContainsKey(hash) ? (bool) visibleWarning[hash] : visibleWarningDef); + } + return true; + } - #region Error - public void Error(object o) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Error, caller.GetHashCode())) - writeLine(" Error:", string.Concat(caller, " - ", o.ToString())); - } - public void Error(string msg) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Error, caller.GetHashCode())) - writeLine(" Error:", string.Concat(caller, " - ", msg)); - } - public void Error(string format, params object[] args) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Error, caller.GetHashCode())) - writeLine(" Error:", string.Concat(caller, " - ", string.Format(format, args))); - } - public void Error(string msg, Exception ex) - { - string caller = debugInfo(); - if (isVisible(MessageLevel.Error, caller.GetHashCode())) - writeLine(" Error:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); - } - #endregion - } - #endregion + /// + /// Set visibility for message level of class:method + /// + /// visible + /// message level + /// class:method + public void Visible(bool visible, MessageLevel messageLevel, string classMethod) + { + int hash = classMethod.GetHashCode(); + switch (messageLevel) + { + case MessageLevel.Debug: + visibleDebug[hash] = visible; + return; + case MessageLevel.Error: + visibleError[hash] = visible; + return; + case MessageLevel.Info: + visibleInfo[hash] = visible; + return; + case MessageLevel.Warning: + visibleWarning[hash] = visible; + return; + } + } + + /// + /// Set visibility for message level of class:method + /// + /// visible + /// message level + /// class:method + public void Visible(bool visible, MessageLevel messageLevel) + { + switch (messageLevel) + { + case MessageLevel.Debug: + visibleDebugDef = visible; + return; + case MessageLevel.Error: + visibleErrorDef = visible; + return; + case MessageLevel.Info: + visibleInfoDef = visible; + return; + case MessageLevel.Warning: + visibleWarningDef = visible; + return; + } + } + + #region Debug + + public void Debug(object o) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Debug, caller.GetHashCode())) + writeLine(" Debug:", string.Concat(caller, " - ", o.ToString())); + } + + public void Debug(string msg) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Debug, caller.GetHashCode())) + writeLine(" Debug:", string.Concat(caller, " - ", msg)); + } + + public void Debug(string format, params object[] args) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Debug, caller.GetHashCode())) + writeLine(" Debug:", string.Concat(caller, " - ", string.Format(format, args))); + } + + public void Debug(string msg, Exception ex) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Debug, caller.GetHashCode())) + writeLine(" Debug:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); + } + + #endregion + + #region Info + + public void Info(object o) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Info, caller.GetHashCode())) + writeLine(" Info:", string.Concat(caller, " - ", o.ToString())); + } + + public void Info(string msg) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Info, caller.GetHashCode())) + writeLine(" Info:", string.Concat(caller, " - ", msg)); + } + + public void Info(string format, params object[] args) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Info, caller.GetHashCode())) + writeLine(" Info:", string.Concat(caller, " - ", string.Format(format, args))); + } + + public void Info(string msg, Exception ex) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Info, caller.GetHashCode())) + writeLine(" Info:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); + } + + #endregion + + #region Warning + + public void Warning(object o) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Warning, caller.GetHashCode())) + writeLine("Warning:", string.Concat(caller, " - ", o.ToString())); + } + + public void Warning(string msg) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Warning, caller.GetHashCode())) + writeLine("Warning:", string.Concat(caller, " - ", msg)); + } + + public void Warning(string format, params object[] args) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Warning, caller.GetHashCode())) + writeLine("Warning:", string.Concat(caller, " - ", string.Format(format, args))); + } + + public void Warning(string msg, Exception ex) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Warning, caller.GetHashCode())) + writeLine("Warning:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); + } + + #endregion + + #region Error + + public void Error(object o) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Error, caller.GetHashCode())) + writeLine(" Error:", string.Concat(caller, " - ", o.ToString())); + } + + public void Error(string msg) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Error, caller.GetHashCode())) + writeLine(" Error:", string.Concat(caller, " - ", msg)); + } + + public void Error(string format, params object[] args) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Error, caller.GetHashCode())) + writeLine(" Error:", string.Concat(caller, " - ", string.Format(format, args))); + } + + public void Error(string msg, Exception ex) + { + string caller = debugInfo(); + if (isVisible(MessageLevel.Error, caller.GetHashCode())) + writeLine(" Error:", string.Concat(caller, " - ", string.Format("{0}\n{1}", msg, ex))); + } + + #endregion + } + + #endregion #endif } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AGIAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AGIAction.cs index 51e3468..0a9bfc0 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AGIAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AGIAction.cs @@ -1,30 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { /// - /// This action lets you execute any AGI command through the Manager interface - /// For example, check the AsterNET.Test project + /// This action lets you execute any AGI command through the Manager interface + /// For example, check the AsterNET.Test project /// public class AgiAction : ManagerAction { - public string Channel { get; set; } - public string Command { get; set; } - /// - /// Get the name of this action, i.e. "AGI". - /// - override public string Action - { - get { return "AGI"; } - } - - /// - /// Creates a new empty AgiAction. + /// Creates a new empty AgiAction. /// public AgiAction(string channel, string command) { @@ -32,6 +15,15 @@ namespace AsterNET.Manager.Action Command = command; } + public string Channel { get; set; } + public string Command { get; set; } + /// + /// Get the name of this action, i.e. "AGI". + /// + public override string Action + { + get { return "AGI"; } + } } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AOCMessageAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AOCMessageAction.cs index 547153d..d2b056d 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AOCMessageAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AOCMessageAction.cs @@ -1,37 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class AOCMessageAction : ManagerAction { - - private string _channel; - private string _channelPrefix; - private string _msgType; - private string _chargeType; - private int _unitAmount; - private int _unitType; - private string _currencyName; - private string _currencyAmount; - private string _currencyMultiplier; - private string _totalType; - private string _aocBillingId; - private string _chargingAssociationId; - private string _chargingAssociationNumber; - private string _chargingrAssociationPlan; - /// - /// Generate an Advice of Charge message on a channel. + /// Generate an Advice of Charge message on a channel. /// public AOCMessageAction() { } /// - /// Generate an Advice of Charge message on a channel. + /// Generate an Advice of Charge message on a channel. /// /// /// @@ -47,22 +26,25 @@ namespace AsterNET.Manager.Action /// /// /// - public AOCMessageAction(string channel, string channelPrefix, string msgType, string chargeType, int unitAmount, int unitType, string currencyName, string currencyAmount, string currencyMultiplier, string totalType, string aocBillingId, string chargingAssociationId, string chargingAssociationNumber, string chargingrAssociationPlan) + public AOCMessageAction(string channel, string channelPrefix, string msgType, string chargeType, int unitAmount, + int unitType, string currencyName, string currencyAmount, string currencyMultiplier, string totalType, + string aocBillingId, string chargingAssociationId, string chargingAssociationNumber, + string chargingrAssociationPlan) { - _channel = channel; - _channelPrefix = channelPrefix; - _msgType = msgType; - _chargeType = chargeType; - _unitAmount = unitAmount; - _unitType = unitType; - _currencyName = currencyName; - _currencyAmount = currencyAmount; - _currencyMultiplier = currencyMultiplier; - _totalType = totalType; - _aocBillingId = aocBillingId; - _chargingAssociationId = chargingAssociationId; - _chargingAssociationNumber = chargingAssociationNumber; - _chargingrAssociationPlan = chargingrAssociationPlan; + Channel = channel; + ChannelPrefix = channelPrefix; + MsgType = msgType; + ChargeType = chargeType; + UnitAmount = unitAmount; + UnitType = unitType; + CurrencyName = currencyName; + CurrencyAmount = currencyAmount; + CurrencyMultiplier = currencyMultiplier; + TotalType = totalType; + AocBillingId = aocBillingId; + ChargingAssociationId = chargingAssociationId; + ChargingAssociationNumber = chargingAssociationNumber; + ChargingrAssociationPlan = chargingrAssociationPlan; } public override string Action @@ -70,88 +52,32 @@ namespace AsterNET.Manager.Action get { return "AOCMessage"; } } - public string Channel - { - get { return _channel; } - set { _channel = value; } - } + public string Channel { get; set; } - public string ChannelPrefix - { - get { return _channelPrefix; } - set { _channelPrefix = value; } - } + public string ChannelPrefix { get; set; } - public string MsgType - { - get { return _msgType; } - set { _msgType = value; } - } + public string MsgType { get; set; } - public string ChargeType - { - get { return _chargeType; } - set { _chargeType = value; } - } + public string ChargeType { get; set; } - public int UnitAmount - { - get { return _unitAmount; } - set { _unitAmount = value; } - } + public int UnitAmount { get; set; } - public int UnitType - { - get { return _unitType; } - set { _unitType = value; } - } + public int UnitType { get; set; } - public string CurrencyName - { - get { return _currencyName; } - set { _currencyName = value; } - } + public string CurrencyName { get; set; } - public string CurrencyAmount - { - get { return _currencyAmount; } - set { _currencyAmount = value; } - } + public string CurrencyAmount { get; set; } - public string CurrencyMultiplier - { - get { return _currencyMultiplier; } - set { _currencyMultiplier = value; } - } + public string CurrencyMultiplier { get; set; } - public string TotalType - { - get { return _totalType; } - set { _totalType = value; } - } + public string TotalType { get; set; } - public string AocBillingId - { - get { return _aocBillingId; } - set { _aocBillingId = value; } - } + public string AocBillingId { get; set; } - public string ChargingAssociationId - { - get { return _chargingAssociationId; } - set { _chargingAssociationId = value; } - } + public string ChargingAssociationId { get; set; } - public string ChargingAssociationNumber - { - get { return _chargingAssociationNumber; } - set { _chargingAssociationNumber = value; } - } + public string ChargingAssociationNumber { get; set; } - public string ChargingrAssociationPlan - { - get { return _chargingrAssociationPlan; } - set { _chargingrAssociationPlan = value; } - } + public string ChargingrAssociationPlan { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AbsoluteTimeoutAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AbsoluteTimeoutAction.cs index 2f55c10..bc85c06 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AbsoluteTimeoutAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AbsoluteTimeoutAction.cs @@ -1,68 +1,70 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted for a call on a given channel.
- /// Note that the timeout is set from the current time forward, not counting the number of seconds the call has already been up.
- /// When setting a new timeout all previous absolute timeouts are cancelled.
- /// When the timeout is reached the call is returned to the T extension so that - /// you can playback an explanatory note to the calling party (the called party will not hear that).
- /// This action corresponds the the AbsoluteTimeout command used in the dialplan. - ///
- public class AbsoluteTimeoutAction : ManagerAction - { - private string channel; - private int timeout; + /// + /// The AbsoluteTimeoutAction sets the absolute maximum amount of time permitted for a call on a given channel.
+ /// Note that the timeout is set from the current time forward, not counting the number of seconds the call has already + /// been up.
+ /// When setting a new timeout all previous absolute timeouts are cancelled.
+ /// When the timeout is reached the call is returned to the T extension so that + /// you can playback an explanatory note to the calling party (the called party will not hear that).
+ /// This action corresponds the the AbsoluteTimeout command used in the dialplan. + ///
+ public class AbsoluteTimeoutAction : ManagerAction + { + #region AbsoluteTimeoutAction() - #region AbsoluteTimeoutAction() - /// - /// Creates a new empty AbsoluteTimeoutAction. - /// - public AbsoluteTimeoutAction() - { - } - #endregion - #region AbsoluteTimeoutAction(channel, timeout) - /// - /// Creates a new AbsoluteTimeoutAction with the given channel and timeout. - /// - /// the name of the channel - /// the timeout in seconds or 0 to cancel the AbsoluteTimeout - public AbsoluteTimeoutAction(string channel, int timeout) - { - this.channel = channel; - this.timeout = timeout; - } - #endregion + /// + /// Creates a new empty AbsoluteTimeoutAction. + /// + public AbsoluteTimeoutAction() + { + } - #region Action - /// - /// Get the name of this action, i.e. "AbsoluteTimeout". - /// - override public string Action - { - get { return "AbsoluteTimeout"; } - } - #endregion - #region Channel - /// - /// Get/Set the name of the channel. - public string Channel - { - get { return channel; } - set { this.channel = value; } - } - #endregion - #region Timeout - /// - /// Get/Set the timeout (in seconds) to set. - /// - public int Timeout - { - get { return timeout; } - set { this.timeout = value; } - } - #endregion - } + #endregion + + #region AbsoluteTimeoutAction(channel, timeout) + + /// + /// Creates a new AbsoluteTimeoutAction with the given channel and timeout. + /// + /// the name of the channel + /// the timeout in seconds or 0 to cancel the AbsoluteTimeout + public AbsoluteTimeoutAction(string channel, int timeout) + { + Channel = channel; + Timeout = timeout; + } + + #endregion + + #region Action + + /// + /// Get the name of this action, i.e. "AbsoluteTimeout". + /// + public override string Action + { + get { return "AbsoluteTimeout"; } + } + + #endregion + + #region Channel + + /// + /// Get/Set the name of the channel. + /// + public string Channel { get; set; } + + #endregion + + #region Timeout + + /// + /// Get/Set the timeout (in seconds) to set. + /// + public int Timeout { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentCallbackLoginAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentCallbackLoginAction.cs index cc86dba..50cf437 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentCallbackLoginAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentCallbackLoginAction.cs @@ -1,107 +1,85 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The AgentCallbackLoginAction sets an agent as logged in with callback.
- /// You can pass an extentsion (and optionally a context) to specify the - /// destination of the callback.
- /// In contrast to the AgentCallbackLogin application that you can use within - /// Asterisk's dialplan, you don't need to know the agent's password when logging - /// in an agent.
- /// Available since Asterisk 1.2 - ///
- public class AgentCallbackLoginAction : ManagerAction - { - private string agent; - private string exten; - private string context; - private bool ackCall; - private long wrapupTime; + /// + /// The AgentCallbackLoginAction sets an agent as logged in with callback.
+ /// You can pass an extentsion (and optionally a context) to specify the + /// destination of the callback.
+ /// In contrast to the AgentCallbackLogin application that you can use within + /// Asterisk's dialplan, you don't need to know the agent's password when logging + /// in an agent.
+ /// Available since Asterisk 1.2 + ///
+ public class AgentCallbackLoginAction : ManagerAction + { + /// + /// Creates a new empty AgentCallbackLoginAction. + /// + public AgentCallbackLoginAction() + { + } - /// - /// Get the name of this action, i.e. "AgentCallbackLogin". - /// - override public string Action - { - get { return "AgentCallbackLogin"; } - } - /// - /// Get/Set the name of the agent to log in, for example "1002".
- /// This is property is mandatory. - ///
- public string Agent - { - get { return this.agent; } - set { this.agent = value; } - } - /// - /// Get/Set the extension to use for callback.
- /// This is property is mandatory. - ///
- public string Exten - { - get { return this.exten; } - set { this.exten = value; } - } - /// - /// Get/Set the context of the extension to use for callback. - /// - public string Context - { - get { return this.context; } - set { this.context = value; } - } - /// - /// Get/Set if an acknowledgement is needed when agent is called back.
- /// true if acknowledgement by '#' is required when agent is called back, false otherwise. - /// This property is optional, it allows you to override the defaults defined in Asterisk's configuration. - ///
- public bool AckCall - { - get { return this.ackCall; } - set { this.ackCall = value; } - } - /// - /// Returns the minimum amount of time (in milliseconds) after disconnecting before the caller can receive a new call.
- /// This property is optional, it allows you to override the defaults defined in Asterisk's configuration. - ///
- public long WrapupTime - { - get { return this.wrapupTime; } - set { this.wrapupTime = value; } - } + /// + /// Creates a new AgentCallbackLoginAction, that logs in the given agent at + /// the given callback extension. + /// + /// the name of the agent to log in + /// the extension that is called to connect a queue member with this agent + public AgentCallbackLoginAction(string agent, string exten) + { + Agent = agent; + Exten = exten; + } - /// - /// Creates a new empty AgentCallbackLoginAction. - /// - public AgentCallbackLoginAction() - { - } - - /// - /// Creates a new AgentCallbackLoginAction, that logs in the given agent at - /// the given callback extension. - /// - /// the name of the agent to log in - /// the extension that is called to connect a queue member with this agent - public AgentCallbackLoginAction(string agent, string exten) - { - this.agent = agent; - this.exten = exten; - } - - /// - /// Creates a new AgentCallbackLoginAction, that logs in the given agent at - /// the given callback extension in the given context. - /// - /// the name of the agent to log in - /// the extension that is called to connect a queue member with this agent - /// the context of the extension to use for callback - public AgentCallbackLoginAction(string agent, string exten, string context) - : this(agent, exten) - { - this.context = context; - } - } + /// + /// Creates a new AgentCallbackLoginAction, that logs in the given agent at + /// the given callback extension in the given context. + /// + /// the name of the agent to log in + /// the extension that is called to connect a queue member with this agent + /// the context of the extension to use for callback + public AgentCallbackLoginAction(string agent, string exten, string context) + : this(agent, exten) + { + Context = context; + } + + /// + /// Get the name of this action, i.e. "AgentCallbackLogin". + /// + public override string Action + { + get { return "AgentCallbackLogin"; } + } + + /// + /// Get/Set the name of the agent to log in, for example "1002".
+ /// This is property is mandatory. + ///
+ public string Agent { get; set; } + + /// + /// Get/Set the extension to use for callback.
+ /// This is property is mandatory. + ///
+ public string Exten { get; set; } + + /// + /// Get/Set the context of the extension to use for callback. + /// + public string Context { get; set; } + + /// + /// Get/Set if an acknowledgement is needed when agent is called back.
+ /// true if acknowledgement by '#' is required when agent is called back, false otherwise. + /// This property is optional, it allows you to override the defaults defined in Asterisk's configuration. + ///
+ public bool AckCall { get; set; } + + /// + /// Returns the minimum amount of time (in milliseconds) after disconnecting before the caller can receive a new call. + ///
+ /// This property is optional, it allows you to override the defaults defined in Asterisk's configuration. + ///
+ public long WrapupTime { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentLogoffAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentLogoffAction.cs index 4a928e3..909ecf0 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentLogoffAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentLogoffAction.cs @@ -1,94 +1,83 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The AgentLogoffAction sets an agent as no longer logged in. - /// - public class AgentLogoffAction : ManagerAction - { - private string agent; - private bool soft; + /// + /// The AgentLogoffAction sets an agent as no longer logged in. + /// + public class AgentLogoffAction : ManagerAction + { + #region Action - #region Action - /// - /// Returns the name of this action, i.e. "AgentLogoff". - /// - /// the name of this action - override public string Action - { - get - { - return "AgentLogoff"; - } - } - #endregion + /// + /// Returns the name of this action, i.e. "AgentLogoff". + /// + /// the name of this action + public override string Action + { + get { return "AgentLogoff"; } + } - #region Agent - /// - /// Returns the name of the agent to log off, for example "1002". - /// - /// the name of the agent to log off - /// Sets the name of the agent to log off, for example "1002".
- /// This is property is mandatory. - ///
- /// the name of the agent to log off - public string Agent - { - get - { - return agent; - } - - set - { - this.agent = value; - } + #endregion - } - #endregion + #region Agent - #region Soft - /// - /// Get/Set whether to hangup existing calls or not.
- /// Default is to hangup existing calls on logoff. - ///
- /// true if existing calls should not be hung up, false otherwise.
- /// null if default should be used. - ///
- public bool Soft - { - get { return soft; } - set { this.soft = value; } - } - #endregion + /// + /// Returns the name of the agent to log off, for example "1002". + /// + /// the name of the agent to log off + /// + /// Sets the name of the agent to log off, for example "1002".
+ /// This is property is mandatory. + ///
+ /// the name of the agent to log off + public string Agent { get; set; } - #region Constructors - AgentLogoffAction() - /// Creates a new empty AgentLogoffAction. - public AgentLogoffAction() - { - } - /// - /// Creates a new AgentLogoffAction that logs off the given agent - /// - /// the name of the agent to log off. - public AgentLogoffAction(string agent) - { - this.agent = agent; - } - #endregion + #endregion - #region Constructors - AgentLogoffAction(string agent, bool soft) - /// - /// Creates a new AgentLogoffAction that logs off the given agent - /// - /// the name of the agent to log off. - /// true if exisiting calls should not be hung up on logout. - public AgentLogoffAction(string agent, bool soft) - : this(agent) - { - this.soft = soft; - } - #endregion - } + #region Soft + + /// + /// Get/Set whether to hangup existing calls or not.
+ /// Default is to hangup existing calls on logoff. + ///
+ /// + /// true if existing calls should not be hung up, false otherwise.
+ /// null if default should be used. + ///
+ public bool Soft { get; set; } + + #endregion + + #region Constructors - AgentLogoffAction() + + /// Creates a new empty AgentLogoffAction. + public AgentLogoffAction() + { + } + + /// + /// Creates a new AgentLogoffAction that logs off the given agent + /// + /// the name of the agent to log off. + public AgentLogoffAction(string agent) + { + Agent = agent; + } + + #endregion + + #region Constructors - AgentLogoffAction(string agent, bool soft) + + /// + /// Creates a new AgentLogoffAction that logs off the given agent + /// + /// the name of the agent to log off. + /// true if exisiting calls should not be hung up on logout. + public AgentLogoffAction(string agent, bool soft) + : this(agent) + { + Soft = soft; + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentsAction.cs index 15236d6..ca06544 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AgentsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AgentsAction.cs @@ -1,41 +1,41 @@ using System; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// The AgentsAction requests the state of all agents.
- /// For each agent an AgentsEvent is generated. - /// After the state of all agents has been reported an AgentsCompleteEvent is generated.
- /// Available since Asterisk 1.2 - ///
- /// - /// - public class AgentsAction : ManagerActionEvent - { - #region Action - /// - /// Get the name of this action, i.e. "Agents". - /// - override public string Action - { - get { return "Agents"; } - } - #endregion + /// + /// The AgentsAction requests the state of all agents.
+ /// For each agent an AgentsEvent is generated. + /// After the state of all agents has been reported an AgentsCompleteEvent is generated.
+ /// Available since Asterisk 1.2 + ///
+ /// + /// + public class AgentsAction : ManagerActionEvent + { + #region Action - #region ActionCompleteEventClass - public override Type ActionCompleteEventClass() - { - return typeof(Event.AgentsCompleteEvent); - } - #endregion + /// + /// Get the name of this action, i.e. "Agents". + /// + public override string Action + { + get { return "Agents"; } + } - #region AgentsAction() - /// - /// Creates a new AgentsAction. - /// - public AgentsAction() - { - } - #endregion - } + #endregion + + #region ActionCompleteEventClass + + public override Type ActionCompleteEventClass() + { + return typeof (AgentsCompleteEvent); + } + + #endregion + + #region AgentsAction() + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/AtxferAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/AtxferAction.cs index f9c6599..8f1dfeb 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/AtxferAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/AtxferAction.cs @@ -1,27 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class AtxferAction : ManagerAction { - - private string _channel; - private string _exten; - private string _context; - private string _priority; - /// - /// Attended transfer. + /// Attended transfer. /// public AtxferAction() { } /// - /// Attended transfer. + /// Attended transfer. /// /// Transferer's channel. /// Extension to transfer to. @@ -29,10 +18,10 @@ namespace AsterNET.Manager.Action /// Priority to transfer to. public AtxferAction(string channel, string exten, string context, string priority) { - _channel = channel; - _exten = exten; - _context = context; - _priority = priority; + Channel = channel; + Exten = exten; + Context = context; + Priority = priority; } public override string Action @@ -41,39 +30,23 @@ namespace AsterNET.Manager.Action } /// - /// Transferer's channel. + /// Transferer's channel. /// - public string Channel - { - get { return _channel; } - set { _channel = value; } - } + public string Channel { get; set; } /// - /// Extension to transfer to. + /// Extension to transfer to. /// - public string Exten - { - get { return _exten; } - set { _exten = value; } - } + public string Exten { get; set; } /// - /// Context to transfer to. + /// Context to transfer to. /// - public string Context - { - get { return _context; } - set { _context = value; } - } + public string Context { get; set; } /// - /// Priority to transfer to. + /// Priority to transfer to. /// - public string Priority - { - get { return _priority; } - set { _priority = value; } - } + public string Priority { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/BridgeAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/BridgeAction.cs index b2dcca4..64d9c78 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/BridgeAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/BridgeAction.cs @@ -1,35 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class BridgeAction : ManagerAction { - - private string _channel1; - private string _channel2; - private string _tone; - /// - /// Bridge two channels already in the PBX. + /// Bridge two channels already in the PBX. /// public BridgeAction() { } /// - /// Bridge two channels already in the PBX. + /// Bridge two channels already in the PBX. /// /// Channel to Bridge to Channel2 /// Channel to Bridge to Channel1 /// Play courtesy tone to Channel 2 [yes|no] public BridgeAction(string channel1, string channel2, string tone) { - _channel1 = channel1; - _channel2 = channel2; - _tone = tone; + Channel1 = channel1; + Channel2 = channel2; + Tone = tone; } public override string Action @@ -37,22 +27,10 @@ namespace AsterNET.Manager.Action get { return "Bridge"; } } - public string Channel1 - { - get { return _channel1; } - set { _channel1 = value; } - } + public string Channel1 { get; set; } - public string Channel2 - { - get { return _channel2; } - set { _channel2 = value; } - } + public string Channel2 { get; set; } - public string Tone - { - get { return _tone; } - set { _tone = value; } - } + public string Tone { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ChallengeAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ChallengeAction.cs index 309b301..20b71eb 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ChallengeAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ChallengeAction.cs @@ -1,50 +1,43 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ChallengeAction requests a challenge from the server to use when logging - /// in using challenge/response. Sending this action to the asterisk server - /// results in a ChallengeResponse being received from the server. - /// - /// - /// - public class ChallengeAction : ManagerAction - { - private string authType; + /// + /// The ChallengeAction requests a challenge from the server to use when logging + /// in using challenge/response. Sending this action to the asterisk server + /// results in a ChallengeResponse being received from the server. + /// + /// + /// + public class ChallengeAction : ManagerAction + { + /// + /// Creates a new empty ChallengeAction with MD5 algorithm + /// + public ChallengeAction() + { + AuthType = "MD5"; + } - /// - /// Get the name of this action, i.e. "Challenge". - /// - override public string Action - { - get { return "Challenge"; } - } - /// - /// Get/Set the digest alogrithm to use. Currently asterisk only supports "MD5". - /// - public string AuthType - { - get { return this.authType; } - set { this.authType = value; } - } - - /// - /// Creates a new empty ChallengeAction with MD5 algorithm - /// - public ChallengeAction() - { - this.authType = "MD5"; - } - - /// - /// Creates a new ChallengeAction that requests a new login challenge for use - /// with the given digest algorithm. - /// - /// the digest alogrithm to use. - public ChallengeAction(string authType) - { - this.authType = authType; - } - } + /// + /// Creates a new ChallengeAction that requests a new login challenge for use + /// with the given digest algorithm. + /// + /// the digest alogrithm to use. + public ChallengeAction(string authType) + { + AuthType = authType; + } + + /// + /// Get the name of this action, i.e. "Challenge". + /// + public override string Action + { + get { return "Challenge"; } + } + + /// + /// Get/Set the digest alogrithm to use. Currently asterisk only supports "MD5". + /// + public string AuthType { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ChangeMonitorAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ChangeMonitorAction.cs index 3fd9c55..a21290c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ChangeMonitorAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ChangeMonitorAction.cs @@ -1,69 +1,69 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ChangeMonitorAction changes the monitoring filename of a channel. - /// It has no effect if the channel is not monitored.
- /// It is implemented in res/res_monitor.c - ///
- public class ChangeMonitorAction : ManagerAction - { - private string channel; - private string file; + /// + /// The ChangeMonitorAction changes the monitoring filename of a channel. + /// It has no effect if the channel is not monitored.
+ /// It is implemented in res/res_monitor.c + ///
+ public class ChangeMonitorAction : ManagerAction + { + #region Action - #region Action - /// - /// Get the name of this action, i.e. "ChangeMonitor". - /// - override public string Action - { - get { return "ChangeMonitor"; } - } - #endregion - #region Channel - /// - /// Get/Set the name of the monitored channel.
- /// This property is mandatory. - ///
- public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - #endregion - #region File - /// - /// Get/Set the name of the file to which the voice data is written.
- /// This property is mandatory. - ///
- public string File - { - get { return this.file; } - set { this.file = value; } - } - #endregion + /// + /// Get the name of this action, i.e. "ChangeMonitor". + /// + public override string Action + { + get { return "ChangeMonitor"; } + } - #region ChangeMonitorAction() - /// - /// Creates a new empty ChangeMonitorAction. - /// - public ChangeMonitorAction() - { - } - #endregion - #region ChangeMonitorAction(string channel, string file) - /// - /// Creates a new ChangeMonitorAction that causes monitoring data for the - /// given channel to be written to the given file(s). - /// - /// the name of the channel that is monitored - /// the (base) name of the file(s) to which the voice data is written - public ChangeMonitorAction(string channel, string file) - { - this.channel = channel; - this.file = file; - } - #endregion - } + #endregion + + #region Channel + + /// + /// Get/Set the name of the monitored channel.
+ /// This property is mandatory. + ///
+ public string Channel { get; set; } + + #endregion + + #region File + + /// + /// Get/Set the name of the file to which the voice data is written.
+ /// This property is mandatory. + ///
+ public string File { get; set; } + + #endregion + + #region ChangeMonitorAction() + + /// + /// Creates a new empty ChangeMonitorAction. + /// + public ChangeMonitorAction() + { + } + + #endregion + + #region ChangeMonitorAction(string channel, string file) + + /// + /// Creates a new ChangeMonitorAction that causes monitoring data for the + /// given channel to be written to the given file(s). + /// + /// the name of the channel that is monitored + /// the (base) name of the file(s) to which the voice data is written + public ChangeMonitorAction(string channel, string file) + { + Channel = channel; + File = file; + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/CommandAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/CommandAction.cs index a8d6d5e..b56c5a7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/CommandAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/CommandAction.cs @@ -1,45 +1,44 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The CommandAction sends a command line interface (CLI) command to the asterisk server.
- /// For a list of supported commands type help on asterisk's command line. - ///
- public class CommandAction : ManagerAction - { - protected internal string command; + /// + /// The CommandAction sends a command line interface (CLI) command to the asterisk server.
+ /// For a list of supported commands type help on asterisk's command line. + ///
+ public class CommandAction : ManagerAction + { + protected internal string command; - /// - /// Get the name of this action, i.e. "Command". - /// - override public string Action - { - get { return "Command"; } - } - /// - /// Get/Set the CLI command to send to the asterisk server. - /// - public string Command - { - get { return this.command; } - set { this.command = value; } - } - - /// - /// Creates a new CommandAction. - /// - public CommandAction() - { - } - - /// - /// Creates a new CommandAction with the given command. - /// - /// the CLI command to execute. - public CommandAction(string command) - { - this.command = command; - } - } + /// + /// Creates a new CommandAction. + /// + public CommandAction() + { + } + + /// + /// Creates a new CommandAction with the given command. + /// + /// the CLI command to execute. + public CommandAction(string command) + { + this.command = command; + } + + /// + /// Get the name of this action, i.e. "Command". + /// + public override string Action + { + get { return "Command"; } + } + + /// + /// Get/Set the CLI command to send to the asterisk server. + /// + public string Command + { + get { return command; } + set { command = value; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeKickAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeKickAction.cs index 651afad..0408f35 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeKickAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeKickAction.cs @@ -1,36 +1,31 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeKickAction : ManagerAction { + /// + /// Removes a specified user from a specified conference. + /// + public ConfbridgeKickAction() + { + } + + /// + /// Removes a specified user from a specified conference. + /// + /// + /// + public ConfbridgeKickAction(string conference, string channel) + { + Conference = conference; + Channel = channel; + } + public string Conference { get; set; } public string Channel { get; set; } public override string Action - { + { get { return "ConfbridgeKick"; } - } - - /// - /// Removes a specified user from a specified conference. - /// - public ConfbridgeKickAction() - { } - - /// - /// Removes a specified user from a specified conference. - /// - /// - /// - public ConfbridgeKickAction(string conference, string channel) - { - this.Conference = conference; - this.Channel = channel; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListAction.cs index efe38b4..a34c60b 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListAction.cs @@ -1,12 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /* https://wiki.asterisk.org/wiki/display/AST/ConfBridge+10#ConfBridge10-ConfBridgeAsteriskManagerInterface%28AMI%29Events Action: ConfbridgeList @@ -14,30 +10,31 @@ namespace AsterNET.Manager.Action */ /// - /// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, - /// followed by a final event called ConfbridgeListComplete + /// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, + /// followed by a final event called ConfbridgeListComplete /// public class ConfbridgeListAction : ManagerActionEvent { + /// + /// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, + /// followed by a final event called ConfbridgeListComplete + /// + /// + public ConfbridgeListAction(string conference) + { + Conference = conference; + } + public string Conference { get; set; } public override string Action - { + { get { return "ConfbridgeList"; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.ConfbridgeListCompleteEvent); - } - - /// - /// Lists all users in a particular ConfBridge conference. ConfbridgeList will follow as separate events, - /// followed by a final event called ConfbridgeListComplete - /// - /// - public ConfbridgeListAction(string conference) - { - this.Conference = conference; - } + } + + public override Type ActionCompleteEventClass() + { + return typeof (ConfbridgeListCompleteEvent); + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListRoomsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListRoomsAction.cs index 53f3099..a66f1da 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListRoomsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeListRoomsAction.cs @@ -1,34 +1,22 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events, - /// followed by a final event called ConfbridgeListRoomsComplete. + /// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events, + /// followed by a final event called ConfbridgeListRoomsComplete. /// public class ConfbridgeListRoomsAction : ManagerActionEvent { - public override string Action - { + { get { return "ConfbridgeListRooms"; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.ConfbridgeListRoomsCompleteEvent); - } - - /// - /// Lists data about all active conferences. ConfbridgeListRooms will follow as separate events, - /// followed by a final event called ConfbridgeListRoomsComplete. - /// - public ConfbridgeListRoomsAction() - { - } + } + + public override Type ActionCompleteEventClass() + { + return typeof (ConfbridgeListRoomsCompleteEvent); + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeLockAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeLockAction.cs index ca40d09..ff1bb7d 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeLockAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeLockAction.cs @@ -1,33 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeLockAction : ManagerAction { + /// + /// Locks a specified conference. + /// + public ConfbridgeLockAction() + { + } + + /// + /// Locks a specified conference. + /// + /// + public ConfbridgeLockAction(string conference) + { + Conference = conference; + } + public string Conference { get; set; } public override string Action - { + { get { return "ConfbridgeLock"; } - } - - /// - /// Locks a specified conference. - /// - public ConfbridgeLockAction() - { } - - /// - /// Locks a specified conference. - /// - /// - public ConfbridgeLockAction(string conference) - { - this.Conference = conference; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeMuteAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeMuteAction.cs index be8b4bf..7b4204b 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeMuteAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeMuteAction.cs @@ -1,36 +1,31 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeMuteAction : ManagerAction { + /// + /// Mutes a specified user in a specified conference. + /// + public ConfbridgeMuteAction() + { + } + + /// + /// Mutes a specified user in a specified conference. + /// + /// + /// + public ConfbridgeMuteAction(string conference, string channel) + { + Conference = conference; + Channel = channel; + } + public string Conference { get; set; } public string Channel { get; set; } public override string Action - { + { get { return "ConfbridgeMute"; } - } - - /// - /// Mutes a specified user in a specified conference. - /// - public ConfbridgeMuteAction() - { } - - /// - /// Mutes a specified user in a specified conference. - /// - /// - /// - public ConfbridgeMuteAction(string conference, string channel) - { - this.Conference = conference; - this.Channel = channel; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeSetSingleVideoSrcAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeSetSingleVideoSrcAction.cs index c883f9f..9e39382 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeSetSingleVideoSrcAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeSetSingleVideoSrcAction.cs @@ -1,35 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeSetSingleVideoSrcAction : ManagerAction { + /// + /// Stops recording a specified conference. + /// + public ConfbridgeSetSingleVideoSrcAction() + { + } + + /// + /// Stops recording a specified conference. + /// + /// + public ConfbridgeSetSingleVideoSrcAction(string conference, string channel) + { + Conference = conference; + Channel = channel; + } + public string Conference { get; set; } public string Channel { get; set; } public override string Action - { + { get { return "ConfbridgeSetSingleVideoSrc"; } - } - - /// - /// Stops recording a specified conference. - /// - public ConfbridgeSetSingleVideoSrcAction() - { } - - /// - /// Stops recording a specified conference. - /// - /// - public ConfbridgeSetSingleVideoSrcAction(string conference, string channel) - { - this.Conference = conference; - this.Channel = channel; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStartRecordAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStartRecordAction.cs index 42ab168..1caff0c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStartRecordAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStartRecordAction.cs @@ -1,39 +1,34 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeStartRecordAction : ManagerAction { + /// + /// Starts recording a specified conference, with an optional filename. + /// If recording is already in progress, an error will be returned. + /// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used. + /// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory. + /// + public ConfbridgeStartRecordAction() + { + } + + /// + /// Starts recording a specified conference, with an optional filename. + /// If recording is already in progress, an error will be returned. + /// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used. + /// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory. + /// + /// + public ConfbridgeStartRecordAction(string conference) + { + Conference = conference; + } + public string Conference { get; set; } public override string Action - { + { get { return "ConfbridgeStartRecord"; } - } - - /// - /// Starts recording a specified conference, with an optional filename. - /// If recording is already in progress, an error will be returned. - /// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used. - /// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory. - /// - public ConfbridgeStartRecordAction() - { } - - /// - /// Starts recording a specified conference, with an optional filename. - /// If recording is already in progress, an error will be returned. - /// If RecordFile is not provided, the default record_file as specified in the conferences Bridge Profile will be used. - /// If record_file is not specified, a file will automatically be generated in Asterisk's monitor directory. - /// - /// - public ConfbridgeStartRecordAction(string conference) - { - this.Conference = conference; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStopRecordAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStopRecordAction.cs index 1255bb4..f83f4cb 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStopRecordAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeStopRecordAction.cs @@ -1,33 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeStopRecordAction : ManagerAction { + /// + /// Stops recording a specified conference. + /// + public ConfbridgeStopRecordAction() + { + } + + /// + /// Stops recording a specified conference. + /// + /// + public ConfbridgeStopRecordAction(string conference) + { + Conference = conference; + } + public string Conference { get; set; } public override string Action - { + { get { return "ConfbridgeStopRecord"; } - } - - /// - /// Stops recording a specified conference. - /// - public ConfbridgeStopRecordAction() - { } - - /// - /// Stops recording a specified conference. - /// - /// - public ConfbridgeStopRecordAction(string conference) - { - this.Conference = conference; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnlockAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnlockAction.cs index 8709b22..a64468e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnlockAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnlockAction.cs @@ -1,33 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeUnlockAction : ManagerAction { + /// + /// Unlocks a specified conference. + /// + public ConfbridgeUnlockAction() + { + } + + /// + /// Unlocks a specified conference. + /// + /// + public ConfbridgeUnlockAction(string conference) + { + Conference = conference; + } + public string Conference { get; set; } public override string Action - { + { get { return "ConfbridgeUnlock"; } - } - - /// - /// Unlocks a specified conference. - /// - public ConfbridgeUnlockAction() - { } - - /// - /// Unlocks a specified conference. - /// - /// - public ConfbridgeUnlockAction(string conference) - { - this.Conference = conference; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnmuteAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnmuteAction.cs index 3d08882..57e9bbd 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnmuteAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ConfbridgeUnmuteAction.cs @@ -1,36 +1,31 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class ConfbridgeUnmuteAction : ManagerAction { + /// + /// Unmutes a specified user in a specified conference. + /// + public ConfbridgeUnmuteAction() + { + } + + /// + /// Unmutes a specified user in a specified conference. + /// + /// + /// + public ConfbridgeUnmuteAction(string conference, string channel) + { + Conference = conference; + Channel = channel; + } + public string Conference { get; set; } public string Channel { get; set; } public override string Action - { + { get { return "ConfbridgeUnmute"; } - } - - /// - /// Unmutes a specified user in a specified conference. - /// - public ConfbridgeUnmuteAction() - { } - - /// - /// Unmutes a specified user in a specified conference. - /// - /// - /// - public ConfbridgeUnmuteAction(string conference, string channel) - { - this.Conference = conference; - this.Channel = channel; - } + } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreSettingsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreSettingsAction.cs index 01a5bf2..3c026c4 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreSettingsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreSettingsAction.cs @@ -1,22 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class CoreSettingsAction : ManagerAction { - /// - /// Show PBX core settings (version etc). - /// - public CoreSettingsAction() - { - } - public override string Action { get { return "CoreSettings"; } } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreShowChannelsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreShowChannelsAction.cs index 17460df..135d575 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreShowChannelsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreShowChannelsAction.cs @@ -1,22 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class CoreShowChannelsAction : ManagerAction { - /// - /// List currently defined channels and some information about them. - /// - public CoreShowChannelsAction() - { - } - public override string Action { get { return "CoreShowChannels"; } } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreStatusAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreStatusAction.cs index de9d2e7..a41d23a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/CoreStatusAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/CoreStatusAction.cs @@ -1,22 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class CoreStatusAction : ManagerAction { - /// - /// Show PBX core status variables. Query for Core PBX status. - /// - public CoreStatusAction() - { - } - public override string Action { get { return "CoreStatus"; } } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/CreateConfigAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/CreateConfigAction.cs index b24b591..88ae95c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/CreateConfigAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/CreateConfigAction.cs @@ -1,31 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class CreateConfigAction : ManagerAction { - - private string _filename; - /// - /// Creates an empty file in the configuration directory. - /// This action will create an empty file in the configuration directory. This action is intended to be used before an UpdateConfig action. + /// Creates an empty file in the configuration directory. + /// This action will create an empty file in the configuration directory. This action is intended to be used before an + /// UpdateConfig action. /// public CreateConfigAction() { } /// - /// Creates an empty file in the configuration directory. - /// This action will create an empty file in the configuration directory. This action is intended to be used before an UpdateConfig action. + /// Creates an empty file in the configuration directory. + /// This action will create an empty file in the configuration directory. This action is intended to be used before an + /// UpdateConfig action. /// /// public CreateConfigAction(string filename) { - _filename = filename; + Filename = filename; } public override string Action @@ -33,10 +27,6 @@ namespace AsterNET.Manager.Action get { return "CreateConfig"; } } - public string Filename - { - get { return _filename; } - set { _filename = value; } - } + public string Filename { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelAction.cs index aeaeeba..0ad578b 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelAction.cs @@ -1,54 +1,41 @@ -using System; -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { - /// - /// /// public class DBDelAction : ManagerAction { - private string family; - private string key; - - public override string Action - { - get { return "DBDel"; } - } - /// - /// Get/Set the the Family of the entry to delete. - /// - public string Family - { - get { return family; } - set { this.family = value; } - } - /// - /// Get/Set the the key of the entry to delete. - /// - public string Key - { - get { return key; } - set { this.key = value; } - } - - /// - /// Creates a new empty DBDelAction. + /// Creates a new empty DBDelAction. /// public DBDelAction() { } /// - /// Creates a new DBDelAction that deletes the value of the database entry - /// with the given key in the given family. + /// Creates a new DBDelAction that deletes the value of the database entry + /// with the given key in the given family. /// /// the family of the key /// the key of the entry to retrieve public DBDelAction(string family, string key) { - this.family = family; - this.key = key; + Family = family; + Key = key; } + + public override string Action + { + get { return "DBDel"; } + } + + /// + /// Get/Set the the Family of the entry to delete. + /// + public string Family { get; set; } + + /// + /// Get/Set the the key of the entry to delete. + /// + public string Key { get; set; } } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelTreeAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelTreeAction.cs index 904a243..d5f1745 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelTreeAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/DBDelTreeAction.cs @@ -1,14 +1,27 @@ -using System; -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { - /// - /// /// public class DBDelTreeAction : ManagerAction { - private string family; - private string key; + /// + /// Creates a new empty DBDelTreeAction. + /// + public DBDelTreeAction() + { + } + + /// + /// Creates a new DBDelTreeAction that deletes the database true + /// with the given key in the given family. + /// + /// the family of the key + /// the key of the entry to retrieve + public DBDelTreeAction(string family, string key) + { + Family = family; + Key = key; + } public override string Action { @@ -16,39 +29,13 @@ namespace AsterNET.Manager.Action } /// - /// Get/Set the the Family of the entry to delete. + /// Get/Set the the Family of the entry to delete. /// - public string Family - { - get { return family; } - set { this.family = value; } - } - /// - /// Get/Set the the key of the entry to delete. - /// - public string Key - { - get { return key; } - set { this.key = value; } - } + public string Family { get; set; } /// - /// Creates a new empty DBDelTreeAction. + /// Get/Set the the key of the entry to delete. /// - public DBDelTreeAction() - { - } - - /// - /// Creates a new DBDelTreeAction that deletes the database true - /// with the given key in the given family. - /// - /// the family of the key - /// the key of the entry to retrieve - public DBDelTreeAction(string family, string key) - { - this.family = family; - this.key = key; - } + public string Key { get; set; } } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/DBGetAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/DBGetAction.cs index f9b8ebb..e0a5f62 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/DBGetAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/DBGetAction.cs @@ -1,67 +1,59 @@ using System; +using AsterNET.Manager.Event; + namespace AsterNET.Manager.Action { - - /// - /// Retrieves an entry in the Asterisk database for a given family and key.
- /// If an entry is found a DBGetResponseEvent is sent by Asterisk containing the - /// value, otherwise a ManagerError indicates that no entry matches. - ///
- /// - public class DBGetAction : ManagerActionEvent - { - private string family; - private string key; + /// + /// Retrieves an entry in the Asterisk database for a given family and key.
+ /// If an entry is found a DBGetResponseEvent is sent by Asterisk containing the + /// value, otherwise a ManagerError indicates that no entry matches. + ///
+ /// + public class DBGetAction : ManagerActionEvent + { + /// + /// Creates a new empty DBGetAction. + /// + public DBGetAction() + { + } - public override string Action - { - get { return "DBGet"; } - } - /// Returns the family of the key. - /// - /// - /// the family of the key. - /// - /// Sets the family of the key. - /// - /// - /// the family of the key. - /// - public string Family - { - get { return family; } - set { this.family = value; } - } - /// - /// Get/Set the the key of the entry to retrieve. - /// - public string Key - { - get { return key; } - set { this.key = value; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.DBGetResponseEvent); - } - - /// - /// Creates a new empty DBGetAction. - /// - public DBGetAction() - { - } - - /// - /// Creates a new DBGetAction that retrieves the value of the database entry - /// with the given key in the given family. - /// - /// the family of the key - /// the key of the entry to retrieve - public DBGetAction(string family, string key) - { - this.family = family; - this.key = key; - } - } + /// + /// Creates a new DBGetAction that retrieves the value of the database entry + /// with the given key in the given family. + /// + /// the family of the key + /// the key of the entry to retrieve + public DBGetAction(string family, string key) + { + Family = family; + Key = key; + } + + public override string Action + { + get { return "DBGet"; } + } + + /// + /// Returns the family of the key. + /// + /// + /// the family of the key. + /// + /// + /// the family of the key. + /// + public string Family { get; set; } + + /// + /// Get/Set the the key of the entry to retrieve. + /// + public string Key { get; set; } + + public override Type ActionCompleteEventClass() + { + return typeof (DBGetResponseEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/DBPutAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/DBPutAction.cs index 55bab64..352b802 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/DBPutAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/DBPutAction.cs @@ -1,64 +1,49 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// Adds or updates an entry in the Asterisk database for a given family, key, and value.
- /// Available since Asterisk 1.2 - ///
- public class DBPutAction : ManagerAction - { - private string family; - private string key; - private string val; + /// + /// Adds or updates an entry in the Asterisk database for a given family, key, and value.
+ /// Available since Asterisk 1.2 + ///
+ public class DBPutAction : ManagerAction + { + /// + /// Creates a new empty DBPutAction. + /// + public DBPutAction() + { + } - override public string Action - { - get { return "DBPut"; } - } - /// - /// Get/Set the family of the key to set. - /// - public string Family - { - get { return this.family; } - set { this.family = value; } - } - /// - /// Get/Set the the key to set. - /// - public string Key - { - get { return this.key; } - set { this.key = value; } - } - /// - /// Get/Set the value to set. - /// - public string Val - { - get { return val; } - set { this.val = value; } - } - - /// - /// Creates a new empty DBPutAction. - /// - public DBPutAction() - { - } - - /// - /// Creates a new DBPutAction that sets the value of the database entry with the given key in the given family. - /// - /// the family of the key - /// the key of the entry to set - /// the value to set - public DBPutAction(string family, string key, string val) - { - this.family = family; - this.key = key; - this.val = val; - } - } + /// + /// Creates a new DBPutAction that sets the value of the database entry with the given key in the given family. + /// + /// the family of the key + /// the key of the entry to set + /// the value to set + public DBPutAction(string family, string key, string val) + { + Family = family; + Key = key; + Val = val; + } + + public override string Action + { + get { return "DBPut"; } + } + + /// + /// Get/Set the family of the key to set. + /// + public string Family { get; set; } + + /// + /// Get/Set the the key to set. + /// + public string Key { get; set; } + + /// + /// Get/Set the value to set. + /// + public string Val { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/EventsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/EventsAction.cs index 04d9865..53a2b14 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/EventsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/EventsAction.cs @@ -1,50 +1,44 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// With the EventsAction you can specify what kind of events should be sent to this manager connection. - /// - public class EventsAction : ManagerAction - { - private string eventMask; + /// + /// With the EventsAction you can specify what kind of events should be sent to this manager connection. + /// + public class EventsAction : ManagerAction + { + /// + /// Creates a new empty EventsAction. + /// + public EventsAction() + { + } - /// - /// Get the name of this action, i.e. "Events". - /// - override public string Action - { - get { return "Events"; } - } - /// - /// Get/Set the event mask.
- /// Set to "on" if all events should be send, "off" if not events should be - /// sent or a combination of "system", "call" and "log" (separated by ',') to - /// specify what kind of events should be sent. - ///
- public string EventMask - { - get { return this.eventMask; } - set { this.eventMask = value; } - } - - /// - /// Creates a new empty EventsAction. - /// - public EventsAction() - { - } - - /// - /// Creates a new EventsAction that applies the given event mask to the current manager connection. - /// - /// the event mask.
- /// Set to "on" if all events should be send, "off" if not events should be sent - /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. - /// - public EventsAction(string eventMask) - { - this.eventMask = eventMask; - } - } + /// + /// Creates a new EventsAction that applies the given event mask to the current manager connection. + /// + /// + /// the event mask.
+ /// Set to "on" if all events should be send, "off" if not events should be sent + /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. + /// + public EventsAction(string eventMask) + { + EventMask = eventMask; + } + + /// + /// Get the name of this action, i.e. "Events". + /// + public override string Action + { + get { return "Events"; } + } + + /// + /// Get/Set the event mask.
+ /// Set to "on" if all events should be send, "off" if not events should be + /// sent or a combination of "system", "call" and "log" (separated by ',') to + /// specify what kind of events should be sent. + ///
+ public string EventMask { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ExtensionStateAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ExtensionStateAction.cs index fccba06..4839edf 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ExtensionStateAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ExtensionStateAction.cs @@ -1,43 +1,38 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ExtensionStateAction queries the state of an extension in a given context. - /// - public class ExtensionStateAction : ManagerAction - { - private string exten; - private string context; + /// + /// The ExtensionStateAction queries the state of an extension in a given context. + /// + public class ExtensionStateAction : ManagerAction + { + #region Action - #region Action - /// - /// Get the name of this action, i.e. "ExtensionState". - /// - override public string Action - { - get { return "ExtensionState"; } - } - #endregion - #region Exten - /// - /// Get/Set the extension to query. - /// - public string Exten - { - get { return exten; } - set { this.exten = value; } - } - #endregion - #region Context - /// - /// Get/Set the name of the context that contains the extension to query. - /// - public string Context - { - get { return context; } - set { this.context = value; } - } - #endregion - } + /// + /// Get the name of this action, i.e. "ExtensionState". + /// + public override string Action + { + get { return "ExtensionState"; } + } + + #endregion + + #region Exten + + /// + /// Get/Set the extension to query. + /// + public string Exten { get; set; } + + #endregion + + #region Context + + /// + /// Get/Set the name of the context that contains the extension to query. + /// + public string Context { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/GetConfigAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/GetConfigAction.cs index 4128217..de7d27a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/GetConfigAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/GetConfigAction.cs @@ -1,54 +1,44 @@ -using System; -using System.Collections.Generic; -using System.Text; using AsterNET.Manager.Response; namespace AsterNET.Manager.Action { - /// - /// The GetConfigAction sends a GetConfig command to the asterisk server. - /// - public class GetConfigAction : ManagerActionResponse - { - private string filename; + /// + /// The GetConfigAction sends a GetConfig command to the asterisk server. + /// + public class GetConfigAction : ManagerActionResponse + { + /// + /// Creates a new GetConfigAction. + /// + public GetConfigAction() + { + } - /// - /// Creates a new GetConfigAction. - /// - public GetConfigAction() - { - } + /// + /// Get the name of this action. + /// + /// the configuration filename. + public GetConfigAction(string filename) + { + Filename = filename; + } - /// - /// Get the name of this action. - /// - public override string Action - { - get { return "GetConfig"; } - } + /// + /// Get the name of this action. + /// + public override string Action + { + get { return "GetConfig"; } + } - /// - /// Get the name of this action. - /// - /// the configuration filename. - /// - public GetConfigAction(string filename) - { - this.filename = filename; - } + /// + /// Get/Set the configuration filename. + /// + public string Filename { get; set; } - /// - /// Get/Set the configuration filename. - /// - public string Filename - { - get { return this.filename; } - set { this.filename = value; } - } - - public override object ActionCompleteResponseClass() - { - return new GetConfigResponse(); - } - } -} + public override object ActionCompleteResponseClass() + { + return new GetConfigResponse(); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/GetVarAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/GetVarAction.cs index 32276c5..459440c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/GetVarAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/GetVarAction.cs @@ -1,65 +1,54 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The GetVarAction queries for a channel variable. - /// - public class GetVarAction : ManagerAction - { - private string channel; - private string varName; + /// + /// The GetVarAction queries for a channel variable. + /// + public class GetVarAction : ManagerAction + { + /// + /// Creates a new empty GetVarAction. + /// + public GetVarAction() + { + } - /// - /// Creates a new empty GetVarAction. - /// - public GetVarAction() - { - } + /// + /// Creates a new GetVarAction that queries for the given global variable. + /// + /// the name of the global variable to query. + public GetVarAction(string variable) + { + Variable = variable; + } - /// - /// Creates a new GetVarAction that queries for the given global variable. - /// - /// the name of the global variable to query. - public GetVarAction(string variable) - { - this.varName = variable; - } + /// + /// Creates a new GetVarAction that queries for the given local channel variable. + /// + /// the name of the channel, for example "SIP/1234-9cd". + /// the name of the variable to query. + public GetVarAction(string channel, string variable) + { + Channel = channel; + Variable = variable; + } - /// - /// Creates a new GetVarAction that queries for the given local channel variable. - /// - /// the name of the channel, for example "SIP/1234-9cd". - /// the name of the variable to query. - public GetVarAction(string channel, string variable) - { - this.channel = channel; - this.varName = variable; - } + /// + /// Get the name of this action, i.e. "GetVar". + /// + public override string Action + { + get { return "GetVar"; } + } - /// - /// Get the name of this action, i.e. "GetVar". - /// - override public string Action - { - get { return "GetVar"; } - } - /// - /// Get/Set the name of the channel, if you query for a local channel variable. - /// Leave empty to query for a global variable. - /// - public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - /// - /// Get/Set the name of the variable to query. - /// - public string Variable - { - get { return this.varName; } - set { this.varName = value; } - } - } + /// + /// Get/Set the name of the channel, if you query for a local channel variable. + /// Leave empty to query for a global variable. + /// + public string Channel { get; set; } + + /// + /// Get/Set the name of the variable to query. + /// + public string Variable { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/HangupAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/HangupAction.cs index 7c7a054..d4a2208 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/HangupAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/HangupAction.cs @@ -1,44 +1,37 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The HangupAction causes the pbx to hang up a given channel. - /// - public class HangupAction : ManagerAction - { - private string channel; + /// + /// The HangupAction causes the pbx to hang up a given channel. + /// + public class HangupAction : ManagerAction + { + /// + /// Creates a new empty HangupAction. + /// + public HangupAction() + { + } - /// - /// Creates a new empty HangupAction. - /// - public HangupAction() - { - } + /// + /// Creates a new HangupAction that hangs up the given channel. + /// + /// the name of the channel to hangup. + public HangupAction(string channel) + { + Channel = channel; + } - /// - /// Creates a new HangupAction that hangs up the given channel. - /// - /// the name of the channel to hangup. - public HangupAction(string channel) - { - this.channel = channel; - } + /// + /// Get the name of this action, i.e. "Hangup". + /// + public override string Action + { + get { return "Hangup"; } + } - /// - /// Get the name of this action, i.e. "Hangup". - /// - override public string Action - { - get { return "Hangup"; } - } - /// - /// Get/Set the name of the channel to hangup. - /// - public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - } + /// + /// Get/Set the name of the channel to hangup. + /// + public string Channel { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ListCommandsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ListCommandsAction.cs index 5f04e22..1c955a9 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ListCommandsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ListCommandsAction.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { - class ListCommandsAction + internal class ListCommandsAction { } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/LoginAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/LoginAction.cs index d2347a0..d759488 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/LoginAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/LoginAction.cs @@ -1,128 +1,113 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The LoginAction authenticates the connection.
- /// A successful login is the precondition for sending any other action except - /// for the ChallengeAction.
- /// An unsuccessful login results in an ManagerError being received from the - /// server with a message set to "Authentication failed" and the socket being - /// closed by Asterisk. - ///
- /// - /// - public class LoginAction : ManagerAction - { - private string username; - private string secret; - private string authType; - private string key; - private string events; + /// + /// The LoginAction authenticates the connection.
+ /// A successful login is the precondition for sending any other action except + /// for the ChallengeAction.
+ /// An unsuccessful login results in an ManagerError being received from the + /// server with a message set to "Authentication failed" and the socket being + /// closed by Asterisk. + ///
+ /// + /// + public class LoginAction : ManagerAction + { + /// + /// Creates a new empty LoginAction. + /// + public LoginAction() + { + } - /// - /// Get the name of this action, i.e. "Login". - /// - override public string Action - { - get { return "Login"; } - } - /// - /// Get/Set the username as configured in asterik's manager.conf. - public string Username - { - get { return this.username; } - set { this.username = value; } - } - /// - /// Get/Set the secret to use when using cleartext login.
- /// The secret contains the user's password as configured in Asterisk's manager.conf.
- /// The secret and key properties are mutually exclusive. - ///
- public string Secret - { - get { return this.secret; } - set { this.secret = value; } - } - /// - /// Get/Set the digest alogrithm when using challenge/response.
- /// The digest algorithm is used to create the key based on the challenge and - /// the user's password.
- /// Currently Asterisk supports only "MD5". - ///
- public string AuthType - { - get { return this.authType; } - set { this.authType = value; } - } - /// - /// Get/Set the key. - /// - public string Key - { - get { return this.key; } - set { this.key = value; } - } - /// - /// Get/Set the event mask.
- /// Set to "on" if all events should be send, "off" if not events should be sent or a combination of - /// "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. - ///
- public string Events - { - get { return this.events; } - set { this.events = value; } - } - - /// - /// Creates a new empty LoginAction. - /// - public LoginAction() - { - } - - /// - /// Creates a new LoginAction that performs a cleartext login.
- /// You should not use cleartext login if you are concerned about security and login with a password hash instead. - ///
- /// the username as configured in Asterisk's manager.conf - /// the user's password as configured in Asterisk's manager.conf - /// - public LoginAction(string username, string secret) - { - this.username = username; - this.secret = secret; - } - - /// - /// Creates a new LoginAction that performs a login via challenge/response. - /// - /// the username as configured in Asterisk's manager.conf - /// the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction. - /// the hash of the user's password and the challenge - public LoginAction(string username, string authType, string key) - { - this.username = username; - this.authType = authType; - this.key = key; - } - - /// - /// Creates a new LoginAction that performs a login via challenge/response. - /// - /// the username as configured in Asterisk's manager.conf - /// the digest alogrithm, must match the digest algorithm that was used with the corresponding ChallengeAction. - /// the hash of the user's password and the challenge - /// the event mask.
- /// Set to "on" if all events should be send, "off" if not events should be sent - /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. - /// - public LoginAction(string username, string authType, string key, string events) - { - this.username = username; - this.authType = authType; - this.key = key; - this.events = events; - } - } + /// + /// Creates a new LoginAction that performs a cleartext login.
+ /// You should not use cleartext login if you are concerned about security and login with a password hash instead. + ///
+ /// the username as configured in Asterisk's manager.conf + /// the user's password as configured in Asterisk's manager.conf + /// + public LoginAction(string username, string secret) + { + Username = username; + Secret = secret; + } + + /// + /// Creates a new LoginAction that performs a login via challenge/response. + /// + /// the username as configured in Asterisk's manager.conf + /// + /// the digest alogrithm, must match the digest algorithm that was used with the corresponding + /// ChallengeAction. + /// + /// the hash of the user's password and the challenge + public LoginAction(string username, string authType, string key) + { + Username = username; + AuthType = authType; + Key = key; + } + + /// + /// Creates a new LoginAction that performs a login via challenge/response. + /// + /// the username as configured in Asterisk's manager.conf + /// + /// the digest alogrithm, must match the digest algorithm that was used with the corresponding + /// ChallengeAction. + /// + /// the hash of the user's password and the challenge + /// + /// the event mask.
+ /// Set to "on" if all events should be send, "off" if not events should be sent + /// or a combination of "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. + /// + public LoginAction(string username, string authType, string key, string events) + { + Username = username; + AuthType = authType; + Key = key; + Events = events; + } + + /// + /// Get the name of this action, i.e. "Login". + /// + public override string Action + { + get { return "Login"; } + } + + /// + /// Get/Set the username as configured in asterik's manager.conf. + /// + public string Username { get; set; } + + /// + /// Get/Set the secret to use when using cleartext login.
+ /// The secret contains the user's password as configured in Asterisk's manager.conf.
+ /// The secret and key properties are mutually exclusive. + ///
+ public string Secret { get; set; } + + /// + /// Get/Set the digest alogrithm when using challenge/response.
+ /// The digest algorithm is used to create the key based on the challenge and + /// the user's password.
+ /// Currently Asterisk supports only "MD5". + ///
+ public string AuthType { get; set; } + + /// + /// Get/Set the key. + /// + public string Key { get; set; } + + /// + /// Get/Set the event mask.
+ /// Set to "on" if all events should be send, "off" if not events should be sent or a combination of + /// "system", "call" and "log" (separated by ',') to specify what kind of events should be sent. + ///
+ public string Events { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/LogoffAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/LogoffAction.cs index 586b9fa..ed32b9d 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/LogoffAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/LogoffAction.cs @@ -1,25 +1,16 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The LogoffAction causes the server to close the connection. - /// - public class LogoffAction : ManagerAction - { - /// - /// Get the name of this action, i.e. "Logoff". - /// - override public string Action - { - get { return "Logoff"; } - } - - /// - /// Creates a new LogoffAction. - /// - public LogoffAction() - { - } - } + /// + /// The LogoffAction causes the server to close the connection. + /// + public class LogoffAction : ManagerAction + { + /// + /// Get the name of this action, i.e. "Logoff". + /// + public override string Action + { + get { return "Logoff"; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxCountAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxCountAction.cs index 7c7b466..2e6c51a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxCountAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxCountAction.cs @@ -1,54 +1,48 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The MailboxCountAction queries the number of unread and read messages in a mailbox.
- /// The MailboxCountAction returns a MailboxStatusResponse. - ///
- /// - public class MailboxCountAction : ManagerAction - { - private string mailbox; + /// + /// The MailboxCountAction queries the number of unread and read messages in a mailbox.
+ /// The MailboxCountAction returns a MailboxStatusResponse. + ///
+ /// + public class MailboxCountAction : ManagerAction + { + /// + /// Creates a new empty MailboxCountAction. + /// + public MailboxCountAction() + { + } - /// - /// Get the name of this action, i.e. "MailboxCount". - /// - override public string Action - { - get { return "MailboxCount"; } - } - /// - /// Get/Set the name of the mailbox to query.
- /// This can either be only the number of the mailbox or a string of the form - /// mailboxnumber@context.If no context is specified "default" is assumed.
- /// This property is mandatory. - ///
- public string Mailbox - { - get { return this.mailbox; } - set { this.mailbox = value; } - } - - /// - /// Creates a new empty MailboxCountAction. - /// - public MailboxCountAction() - { - } - - /// - /// Creates a new MailboxCountAction that queries the number of unread and - /// read messages in the given mailbox. - /// - /// the name of the mailbox to query.
- /// This can either be only the number of the mailbox or a string - /// of the form mailboxnumber@context.If no context is specified - /// "default" is assumed. - /// - public MailboxCountAction(string mailbox) - { - this.mailbox = mailbox; - } - } + /// + /// Creates a new MailboxCountAction that queries the number of unread and + /// read messages in the given mailbox. + /// + /// + /// the name of the mailbox to query.
+ /// This can either be only the number of the mailbox or a string + /// of the form mailboxnumber@context.If no context is specified + /// "default" is assumed. + /// + public MailboxCountAction(string mailbox) + { + Mailbox = mailbox; + } + + /// + /// Get the name of this action, i.e. "MailboxCount". + /// + public override string Action + { + get { return "MailboxCount"; } + } + + /// + /// Get/Set the name of the mailbox to query.
+ /// This can either be only the number of the mailbox or a string of the form + /// mailboxnumber@context.If no context is specified "default" is assumed.
+ /// This property is mandatory. + ///
+ public string Mailbox { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxStatusAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxStatusAction.cs index 43ca4f7..c695299 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxStatusAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/MailboxStatusAction.cs @@ -1,57 +1,51 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The MailboxStatusAction checks if a mailbox contains waiting messages.
- /// The MailboxStatusAction returns a MailboxStatusResponse. - ///
- /// - public class MailboxStatusAction : ManagerAction - { - private string mailbox; + /// + /// The MailboxStatusAction checks if a mailbox contains waiting messages.
+ /// The MailboxStatusAction returns a MailboxStatusResponse. + ///
+ /// + public class MailboxStatusAction : ManagerAction + { + /// + /// Creates a new empty MailboxStatusAction. + /// + public MailboxStatusAction() + { + } - /// - /// Get the name of this action, i.e. "MailboxStatus". - /// - override public string Action - { - get { return "MailboxStatus"; } - } - /// - /// Get/Set the name of the mailbox to query.
- /// This can either be only the name of the mailbox or a string of the form - /// mailboxnumber@context. If no context is specified "default" is assumed.
- /// Multiple mailboxes may be given, separated by ','. In this case the - /// action checks whether at least one of the given mailboxes has waiting - /// messages.
- /// This property is mandatory.
- /// Example: "1234,1235@mycontext" - ///
- public string Mailbox - { - get { return this.mailbox; } - set { this.mailbox = value; } - } - - /// - /// Creates a new empty MailboxStatusAction. - /// - public MailboxStatusAction() - { - } - - /// - /// Creates a new MailboxStatusAction that checks for waiting messages in the given mailbox. - /// - /// the name of the mailbox to check.
- /// This can either be only the number of the mailbox or a string - /// of the form mailboxnumber@context.If no context is specified - /// "default" is assumed. - /// - public MailboxStatusAction(string mailbox) - { - this.mailbox = mailbox; - } - } + /// + /// Creates a new MailboxStatusAction that checks for waiting messages in the given mailbox. + /// + /// + /// the name of the mailbox to check.
+ /// This can either be only the number of the mailbox or a string + /// of the form mailboxnumber@context.If no context is specified + /// "default" is assumed. + /// + public MailboxStatusAction(string mailbox) + { + Mailbox = mailbox; + } + + /// + /// Get the name of this action, i.e. "MailboxStatus". + /// + public override string Action + { + get { return "MailboxStatus"; } + } + + /// + /// Get/Set the name of the mailbox to query.
+ /// This can either be only the name of the mailbox or a string of the form + /// mailboxnumber@context. If no context is specified "default" is assumed.
+ /// Multiple mailboxes may be given, separated by ','. In this case the + /// action checks whether at least one of the given mailboxes has waiting + /// messages.
+ /// This property is mandatory.
+ /// Example: "1234,1235@mycontext" + ///
+ public string Mailbox { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerAction.cs index cd5d8e2..ee2f920 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerAction.cs @@ -1,66 +1,66 @@ -using System.Text; -using System.Collections.Generic; - namespace AsterNET.Manager.Action { - /// - /// This class implements the ManagerAction interface - /// and can serve as base class for your concrete Action implementations. - /// - public abstract class ManagerAction - { - private string actionId; - private string server; - private string proxyKey; + /// + /// This class implements the ManagerAction interface + /// and can serve as base class for your concrete Action implementations. + /// + public abstract class ManagerAction + { + private string actionId; + private string proxyKey; + private string server; - /// - /// Manager API Action key. Also use as ProxyAction key to ProxyAction actions. - /// - public abstract string Action - { - get; - } + /// + /// Manager API Action key. Also use as ProxyAction key to ProxyAction actions. + /// + public abstract string Action { get; } - #region ActionId - public string ActionId - { - get { return this.actionId; } - set { this.actionId = value; } - } - #endregion + #region ActionId - #region Server - /// - /// Specify a server to which to send your commands (x.x.x.x or hostname).
- /// This should match the server name specified in your config file's "host" entry. - /// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations. - ///
- public string Server - { - get { return this.server; } - set { this.server = value; } - } - #endregion + public string ActionId + { + get { return this.actionId; } + set { this.actionId = value; } + } - #region ProxyKey - /// - /// You can use this as a simple authentication mechanism.
- /// Rather than have to login with a username & password, - /// you can specify a ProxyKey that must be passed from - /// a client before requests are processed.
- /// This is helpful in situations where you would like to authenticate and - /// execute an action in a single step. - ///
- public virtual string ProxyKey - { - get { return this.proxyKey; } - set { this.proxyKey = value; } - } - #endregion + #endregion - public override string ToString() - { - return Helper.ToString(this); - } - } -} + #region Server + + /// + /// Specify a server to which to send your commands (x.x.x.x or hostname).
+ /// This should match the server name specified in your config file's "host" entry. + /// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations. + ///
+ public string Server + { + get { return this.server; } + set { this.server = value; } + } + + #endregion + + #region ProxyKey + + /// + /// You can use this as a simple authentication mechanism.
+ /// Rather than have to login with a username & password, + /// you can specify a ProxyKey that must be passed from + /// a client before requests are processed.
+ /// This is helpful in situations where you would like to authenticate and + /// execute an action in a single step. + ///
+ public virtual string ProxyKey + { + get { return this.proxyKey; } + set { this.proxyKey = value; } + } + + #endregion + + public override string ToString() + { + return Helper.ToString(this); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionEvent.cs index a7b5ae6..7d6e946 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionEvent.cs @@ -2,19 +2,19 @@ using System; namespace AsterNET.Manager.Action { - /// - /// The ManagerActionEvent is implemented by ManagerActions that - /// return their result not in a ManagerResponse but by sending a series of events.
- /// The event type that indicates that Asterisk is finished is returned by the - /// ActionCompleteEventClass property. - ///
- /// - public abstract class ManagerActionEvent : ManagerAction - { - /// - /// Returns the event type that indicates that Asterisk is finished sending response events for this action. - /// - /// - public abstract Type ActionCompleteEventClass(); - } + /// + /// The ManagerActionEvent is implemented by ManagerActions that + /// return their result not in a ManagerResponse but by sending a series of events.
+ /// The event type that indicates that Asterisk is finished is returned by the + /// ActionCompleteEventClass property. + ///
+ /// + public abstract class ManagerActionEvent : ManagerAction + { + /// + /// Returns the event type that indicates that Asterisk is finished sending response events for this action. + /// + /// + public abstract Type ActionCompleteEventClass(); + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionResponse.cs index f1f36e0..48ee727 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ManagerActionResponse.cs @@ -1,21 +1,18 @@ -using System; -using AsterNET.Manager.Response; - namespace AsterNET.Manager.Action { - /// - /// The ManagerActionResponse is implemented by ManagerActions that - /// return their result in a custom ManagerResponse
- /// The response type that indicates that Asterisk is finished is returned by the - /// ActionCompleteResponseClass property. - ///
- /// - public abstract class ManagerActionResponse : ManagerAction - { - /// - /// Returns the response type that indicates that Asterisk is finished sending response for this action. - /// - /// - public abstract object ActionCompleteResponseClass(); - } + /// + /// The ManagerActionResponse is implemented by ManagerActions that + /// return their result in a custom ManagerResponse
+ /// The response type that indicates that Asterisk is finished is returned by the + /// ActionCompleteResponseClass property. + ///
+ /// + public abstract class ManagerActionResponse : ManagerAction + { + /// + /// Returns the response type that indicates that Asterisk is finished sending response for this action. + /// + /// + public abstract object ActionCompleteResponseClass(); + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/MonitorAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/MonitorAction.cs index 9e50750..62d1369 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/MonitorAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/MonitorAction.cs @@ -1,130 +1,125 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The MonitorAction starts monitoring (recording) a channel.
- /// It is implemented in res/res_monitor.c - ///
- public class MonitorAction : ManagerAction - { - private string channel; - private string file; - private string format; - private bool mix; + /// + /// The MonitorAction starts monitoring (recording) a channel.
+ /// It is implemented in res/res_monitor.c + ///
+ public class MonitorAction : ManagerAction + { + #region Action - #region Action - /// - /// Get the name of this action, i.e. "Monitor". - /// - override public string Action - { - get { return "Monitor"; } - } - #endregion + /// + /// Get the name of this action, i.e. "Monitor". + /// + public override string Action + { + get { return "Monitor"; } + } - #region Channel - /// - /// Get/Set the name of the channel to monitor.
- /// This property is mandatory. - ///
- public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - #endregion + #endregion - #region File - /// - /// Get/Set the name of the file to which the voice data is written.
- /// If this property is not set it defaults to to the channel name as per CLI with the '/' replaced by '-'. - ///
- public string File - { - get { return this.file; } - set { this.file = value; } - } - #endregion + #region Channel - #region Format - /// - /// Get/Set the format to use for encoding the voice files.
- /// If this property is not set it defaults to "wav". - ///
- public string Format - { - get { return this.format; } - set { this.format = value; } - } - #endregion + /// + /// Get/Set the name of the channel to monitor.
+ /// This property is mandatory. + ///
+ public string Channel { get; set; } - #region Mix - /// - /// Returns true if the two voice files should be joined at the end of the call. - /// - public bool Mix - { - get { return this.mix; } - set { this.mix = value; } - } - #endregion + #endregion - #region MonitorAction() - /// - /// Creates a new empty MonitorAction. - /// - public MonitorAction() - { - } - #endregion + #region File - #region MonitorAction(string channel, string file) - /// - /// Creates a new MonitorAction that starts monitoring the given channel and - /// writes voice data to the given file(s). - /// - /// the name of the channel to monitor - /// the (base) name of the file(s) to which the voice data is written - public MonitorAction(string channel, string file) - { - this.channel = channel; - this.file = file; - } - #endregion + /// + /// Get/Set the name of the file to which the voice data is written.
+ /// If this property is not set it defaults to to the channel name as per CLI with the '/' replaced by '-'. + ///
+ public string File { get; set; } - #region MonitorAction(string channel, string file) - /// - /// Creates a new MonitorAction that starts monitoring the given channel and - /// writes voice data to the given file(s). - /// - /// the name of the channel to monitor - /// the (base) name of the file(s) to which the voice data is written - /// the format to use for encoding the voice files - public MonitorAction(string channel, string file, string format) - { - this.channel = channel; - this.file = file; - this.format = format; - } - #endregion + #endregion - #region MonitorAction(string channel, string file, string format, int mix) - /// - /// Creates a new MonitorAction that starts monitoring the given channel and - /// writes voice data to the given file(s). - /// - /// the name of the channel to monitor - /// the (base) name of the file(s) to which the voice data is written - /// the format to use for encoding the voice files - /// true if the two voice files should be joined at the end of the call - public MonitorAction(string channel, string file, string format, bool mix) - { - this.channel = channel; - this.file = file; - this.format = format; - this.mix = mix; - } - #endregion - } + #region Format + + /// + /// Get/Set the format to use for encoding the voice files.
+ /// If this property is not set it defaults to "wav". + ///
+ public string Format { get; set; } + + #endregion + + #region Mix + + /// + /// Returns true if the two voice files should be joined at the end of the call. + /// + public bool Mix { get; set; } + + #endregion + + #region MonitorAction() + + /// + /// Creates a new empty MonitorAction. + /// + public MonitorAction() + { + } + + #endregion + + #region MonitorAction(string channel, string file) + + /// + /// Creates a new MonitorAction that starts monitoring the given channel and + /// writes voice data to the given file(s). + /// + /// the name of the channel to monitor + /// the (base) name of the file(s) to which the voice data is written + public MonitorAction(string channel, string file) + { + Channel = channel; + File = file; + } + + #endregion + + #region MonitorAction(string channel, string file) + + /// + /// Creates a new MonitorAction that starts monitoring the given channel and + /// writes voice data to the given file(s). + /// + /// the name of the channel to monitor + /// the (base) name of the file(s) to which the voice data is written + /// the format to use for encoding the voice files + public MonitorAction(string channel, string file, string format) + { + Channel = channel; + File = file; + Format = format; + } + + #endregion + + #region MonitorAction(string channel, string file, string format, int mix) + + /// + /// Creates a new MonitorAction that starts monitoring the given channel and + /// writes voice data to the given file(s). + /// + /// the name of the channel to monitor + /// the (base) name of the file(s) to which the voice data is written + /// the format to use for encoding the voice files + /// true if the two voice files should be joined at the end of the call + public MonitorAction(string channel, string file, string format, bool mix) + { + Channel = channel; + File = file; + Format = format; + Mix = mix; + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs index 56313a7..0873068 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/OriginateAction.cs @@ -1,239 +1,224 @@ using System; -using System.Collections; using System.Collections.Generic; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// The OriginateAction generates an outgoing call to the extension in the given - /// context with the given priority or to a given application with optional - /// parameters.
- /// If you want to connect to an extension use the properties context, exten and - /// priority. If you want to connect to an application use the properties - /// application and data if needed. Note that no call detail record will be - /// written when directly connecting to an application, so it may be better to - /// connect to an extension that starts the application you wish to connect to.
- /// The response to this action is sent when the channel has been answered and - /// asterisk starts connecting it to the given extension. So be careful not to - /// choose a too short timeout when waiting for the response.
- /// If you set async to true Asterisk reports an OriginateSuccess- - /// and OriginateFailureEvents. The action id of these events equals the action - /// id of this OriginateAction. - ///
- /// - /// - public class OriginateAction : ManagerActionEvent - { - private string channel; - private string exten; - private string context; - private string priority; - private int timeout; - private string callerId; - private Dictionary variables; - private string account; - private string application; - private string data; - private bool async; + /// + /// The OriginateAction generates an outgoing call to the extension in the given + /// context with the given priority or to a given application with optional + /// parameters.
+ /// If you want to connect to an extension use the properties context, exten and + /// priority. If you want to connect to an application use the properties + /// application and data if needed. Note that no call detail record will be + /// written when directly connecting to an application, so it may be better to + /// connect to an extension that starts the application you wish to connect to.
+ /// The response to this action is sent when the channel has been answered and + /// asterisk starts connecting it to the given extension. So be careful not to + /// choose a too short timeout when waiting for the response.
+ /// If you set async to true Asterisk reports an OriginateSuccess- + /// and OriginateFailureEvents. The action id of these events equals the action + /// id of this OriginateAction. + ///
+ /// + /// + public class OriginateAction : ManagerActionEvent + { + private Dictionary variables; - #region Action - /// - /// Get the name of this action, i.e. "Originate". - /// - override public string Action - { - get { return "Originate"; } - } - #endregion + #region Action - #region Account - /// - /// Get/Set the account code to use for the originated call. - /// The account code is included in the call detail record generated for this call and will be used for billing. - /// - public string Account - { - get { return account; } - set { this.account = value; } - } - #endregion + /// + /// Get the name of this action, i.e. "Originate". + /// + public override string Action + { + get { return "Originate"; } + } - #region CallerId - /// - /// Get/Set the caller id to set on the outgoing channel. - /// - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - #endregion + #endregion - #region Channel - /// - /// Get/Set Channel on which to originate the call (The same as you specify in the Dial application command)
- /// This property is required. - ///
- public string Channel - { - get { return channel; } - set { this.channel = value; } - } - #endregion + #region Account - #region Context - /// - /// Get/Set the name of the context of the extension to connect to. - /// If you set the context you also have to set the exten and priority properties. - /// - public string Context - { - get { return context; } - set { this.context = value; } - } - #endregion + /// + /// Get/Set the account code to use for the originated call. + /// The account code is included in the call detail record generated for this call and will be used for billing. + /// + public string Account { get; set; } - #region Exten - /// - /// Get/Ser the extension to connect to. - /// If you set the extension you also have to set the context and priority properties. - /// - public string Exten - { - get { return exten; } - set { this.exten = value; } - } - #endregion + #endregion - #region Priority - /// - /// Get /Set the priority of the extension to connect to. - /// If you set the priority you also have to set the context and exten properties. - /// - public string Priority - { - get { return priority; } - set { this.priority = value; } - } - #endregion + #region CallerId - #region Application - /// - /// Get/Set Application to use on connect (use Data for parameters) - /// - public string Application - { - get { return application; } - set { this.application = value; } - } - #endregion + /// + /// Get/Set the caller id to set on the outgoing channel. + /// + public string CallerId { get; set; } - #region Data - /// - /// Get/Set the parameters to pass to the application. - /// Data if Application parameter is user - /// - /// Sets the parameters to pass to the application. - public string Data - { - get { return data; } - set { this.data = value; } - } - #endregion + #endregion - #region Async - /// - /// Get/Set true if this is a fast origination.
- /// For the origination to be asynchronous (allows multiple calls to be generated without waiting for a response).
- /// Will send OriginateSuccess- and OriginateFailureEvents. - ///
- public bool Async - { - get { return async; } - set { this.async = value; } - } - #endregion + #region Channel - #region ActionCompleteEventClass - public override Type ActionCompleteEventClass() - { - return typeof(Event.OriginateResponseEvent); - } - #endregion + /// + /// Get/Set Channel on which to originate the call (The same as you specify in the Dial application command)
+ /// This property is required. + ///
+ public string Channel { get; set; } - #region Timeout - /// - /// Get/Set the timeout for the origination in seconds.
- /// The channel must be answered within this time, otherwise the origination - /// is considered to have failed and an OriginateFailureEvent is generated.
- /// If not set, Asterisk assumes a default value of 30000 meaning 30 seconds. - ///
- public int Timeout - { - get { return timeout; } - set { this.timeout = value; } - } - #endregion + #endregion - #region Variable - /// - /// Get/Set the variables to set on the originated call.
- /// Variable assignments are of the form "VARNAME=VALUE". You can specify - /// multiple variable assignments separated by the '|' character.
- /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def". - ///
- public string Variable - { - get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); } - set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); } - } - #endregion + #region Context - #region GetVariables() - /// - /// Get the variables dictionary to set on the originated call. - /// - public Dictionary GetVariables() - { - return variables; - } - #endregion + /// + /// Get/Set the name of the context of the extension to connect to. + /// If you set the context you also have to set the exten and priority properties. + /// + public string Context { get; set; } - #region SetVariables(IDictionary vars) - /// - /// Set the variables dictionary to set on the originated call. - /// - public void SetVariables(Dictionary vars) - { - this.variables = vars; - } - #endregion + #endregion - #region GetVariable(string name, string val) - /// - /// Gets a variable on the originated call. Replaces any existing variable with the same name. - /// - public string GetVariable(string key) - { - if (variables == null) - return string.Empty; - return variables[key]; - } - #endregion + #region Exten - #region SetVariable(string name, string val) - /// - /// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. - /// - public void SetVariable(string key, string value) - { - if (variables == null) - variables = new Dictionary(); - if (variables.ContainsKey(key)) - variables[key] = value; - else - variables.Add(key, value); - } - #endregion - } + /// + /// Get/Ser the extension to connect to. + /// If you set the extension you also have to set the context and priority properties. + /// + public string Exten { get; set; } + + #endregion + + #region Priority + + /// + /// Get /Set the priority of the extension to connect to. + /// If you set the priority you also have to set the context and exten properties. + /// + public string Priority { get; set; } + + #endregion + + #region Application + + /// + /// Get/Set Application to use on connect (use Data for parameters) + /// + public string Application { get; set; } + + #endregion + + #region Data + + /// + /// Get/Set the parameters to pass to the application. + /// Data if Application parameter is user + /// + /// Sets the parameters to pass to the application. + public string Data { get; set; } + + #endregion + + #region Async + + /// + /// Get/Set true if this is a fast origination.
+ /// For the origination to be asynchronous (allows multiple calls to be generated without waiting for a response). + ///
+ /// Will send OriginateSuccess- and OriginateFailureEvents. + ///
+ public bool Async { get; set; } + + #endregion + + #region ActionCompleteEventClass + + public override Type ActionCompleteEventClass() + { + return typeof (OriginateResponseEvent); + } + + #endregion + + #region Timeout + + /// + /// Get/Set the timeout for the origination in seconds.
+ /// The channel must be answered within this time, otherwise the origination + /// is considered to have failed and an OriginateFailureEvent is generated.
+ /// If not set, Asterisk assumes a default value of 30000 meaning 30 seconds. + ///
+ public int Timeout { get; set; } + + #endregion + + #region Variable + + /// + /// Get/Set the variables to set on the originated call.
+ /// Variable assignments are of the form "VARNAME=VALUE". You can specify + /// multiple variable assignments separated by the '|' character.
+ /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def". + ///
+ public string Variable + { + get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); } + set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); } + } + + #endregion + + #region GetVariables() + + /// + /// Get the variables dictionary to set on the originated call. + /// + public Dictionary GetVariables() + { + return variables; + } + + #endregion + + #region SetVariables(IDictionary vars) + + /// + /// Set the variables dictionary to set on the originated call. + /// + public void SetVariables(Dictionary vars) + { + variables = vars; + } + + #endregion + + #region GetVariable(string name, string val) + + /// + /// Gets a variable on the originated call. Replaces any existing variable with the same name. + /// + public string GetVariable(string key) + { + if (variables == null) + return string.Empty; + return variables[key]; + } + + #endregion + + #region SetVariable(string name, string val) + + /// + /// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. + /// + public void SetVariable(string key, string value) + { + if (variables == null) + variables = new Dictionary(); + if (variables.ContainsKey(key)) + variables[key] = value; + else + variables.Add(key, value); + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ParkAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ParkAction.cs index 3b32809..f470106 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ParkAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ParkAction.cs @@ -1,75 +1,26 @@ -using System; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { /// - /// The ParkAction allows to send a Channel to a Parking lot.
- /// A successful login is the precondition for sending for that + /// The ParkAction allows to send a Channel to a Parking lot.
+ /// A successful login is the precondition for sending for that ///
- public class ParkAction : ManagerAction { - private string channel; - private string channel2; - private string timeout; - private string parkinglot; - /// - /// Get the name of this action, i.e. "Park". - /// - override public string Action - { - get { return "Park"; } - } - /// - /// Set the Channel which should be parked - /// - public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - /// - /// Set the Channel where the Call will end up after the timeout is reached. - /// - public string Channel2 - { - get { return this.channel2; } - set { this.channel2 = value; } - } - - /// - /// Timeout in msec, after timeout is reached call will come back to channel2 - /// - public string Timeout - { - get { return this.timeout; } - set { this.timeout = value; } - } - /// - /// Set the Parking lot. - /// - public string Parkinglot - { - get { return this.parkinglot; } - set { this.parkinglot = value; } - } - - /// - /// Creates a new ParkAction. + /// Creates a new ParkAction. /// /// /// /// public ParkAction(string channel, string channel2, string timeout) { - this.channel = channel; - this.channel2 = channel2; - this.timeout = timeout; + this.Channel = channel; + this.Channel2 = channel2; + this.Timeout = timeout; } /// - /// Creates a new ParkAction.
+ /// Creates a new ParkAction.
///
/// Set the Channel which should be parked /// Set the Channel where the Call will end up after the timeout is reached. @@ -77,10 +28,38 @@ namespace AsterNET.Manager.Action /// Set the Parking lot. public ParkAction(string channel, string channel2, string timeout, string parkinglot) { - this.channel = channel; - this.channel2 = channel2; - this.timeout = timeout; - this.parkinglot = parkinglot; + this.Channel = channel; + this.Channel2 = channel2; + this.Timeout = timeout; + this.Parkinglot = parkinglot; } + + /// + /// Get the name of this action, i.e. "Park". + /// + public override string Action + { + get { return "Park"; } + } + + /// + /// Set the Channel which should be parked + /// + public string Channel { get; set; } + + /// + /// Set the Channel where the Call will end up after the timeout is reached. + /// + public string Channel2 { get; set; } + + /// + /// Timeout in msec, after timeout is reached call will come back to channel2 + /// + public string Timeout { get; set; } + + /// + /// Set the Parking lot. + /// + public string Parkinglot { get; set; } } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ParkedCallsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ParkedCallsAction.cs index 6e7111f..12c3ebc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ParkedCallsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ParkedCallsAction.cs @@ -1,32 +1,26 @@ using System; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// The ParkedCallsAction requests a list of all currently parked calls.
- /// For each active channel a ParkedCallEvent is generated. After all parked - /// calls have been reported a ParkedCallsCompleteEvent is generated. - ///
- /// - /// - public class ParkedCallsAction : ManagerActionEvent - { - /// Get the name of this action, i.e. "ParkedCalls". - public override string Action - { - get { return "ParkedCalls"; } - } + /// + /// The ParkedCallsAction requests a list of all currently parked calls.
+ /// For each active channel a ParkedCallEvent is generated. After all parked + /// calls have been reported a ParkedCallsCompleteEvent is generated. + ///
+ /// + /// + public class ParkedCallsAction : ManagerActionEvent + { + /// Get the name of this action, i.e. "ParkedCalls". + public override string Action + { + get { return "ParkedCalls"; } + } - public override Type ActionCompleteEventClass() - { - return typeof(Event.ParkedCallsCompleteEvent); - } - - /// - /// Creates a new ParkedCallsAction. - /// - public ParkedCallsAction() - { - } - } + public override Type ActionCompleteEventClass() + { + return typeof (ParkedCallsCompleteEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/PingAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/PingAction.cs index 8a2a0e0..a183836 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/PingAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/PingAction.cs @@ -1,26 +1,17 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The PingAction will ellicit a 'Pong' response, it is used to keep the manager - /// connection open and performs no operation. - /// - public class PingAction : ManagerAction - { - /// - /// Get the name of this action, i.e. "Ping". - /// - override public string Action - { - get { return "Ping"; } - } - - /// - /// Creates a new PingAction. - /// - public PingAction() - { - } - } + /// + /// The PingAction will ellicit a 'Pong' response, it is used to keep the manager + /// connection open and performs no operation. + /// + public class PingAction : ManagerAction + { + /// + /// Get the name of this action, i.e. "Ping". + /// + public override string Action + { + get { return "Ping"; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ProxyAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ProxyAction.cs index 4183d34..8468838 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ProxyAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ProxyAction.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace AsterNET.Manager.Action { - public abstract class ProxyAction : ManagerAction - { - } -} + public abstract class ProxyAction : ManagerAction + { + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueAddAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueAddAction.cs index 89a1653..0665241 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueAddAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueAddAction.cs @@ -1,120 +1,98 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The QueueAddAction adds a new member to a queue.
- /// It is implemented in apps/app_queue.c - ///
- public class QueueAddAction : ManagerAction - { - private string queue; - private string iface; - private string memberName; - private int penalty; - private bool paused; + /// + /// The QueueAddAction adds a new member to a queue.
+ /// It is implemented in apps/app_queue.c + ///
+ public class QueueAddAction : ManagerAction + { + /// + /// Creates a new empty QueueAddAction. + /// + public QueueAddAction() + { + } - /// - /// Get the name of this action, i.e. "QueueAdd". - /// - override public string Action - { - get { return "QueueAdd"; } - } - /// - /// Get/Set the name of the queue the new member will be added to.
- /// This property is mandatory. - ///
- public string Queue - { - get { return this.queue; } - set { this.queue = value; } - } - /// - /// Get/Set the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".
- /// This property is mandatory. - ///
- public string Interface - { - get { return this.iface; } - set { this.iface = value; } - } - /// - /// Get/Set the member to add. - /// - public string MemberName - { - get { return this.memberName; } - set { this.memberName = value; } - } - /// - /// Get/Set the penalty for this member.
- /// The penalty must be a positive integer or 0 for no penalty. If it is not set 0 is assumed.
- /// When calls are distributed members with higher penalties are considered last. - ///
- public int Penalty - { - get { return this.penalty; } - set { this.penalty = value; } - } - /// - /// Get/Set if the queue member should be paused when added.
- /// true if the queue member should be paused when added. - ///
- public bool Paused - { - get { return this.paused; } - set { this.paused = value; } - } - - /// - /// Creates a new empty QueueAddAction. - /// - public QueueAddAction() - { - } - - /// - /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue. - /// - /// the name of the queue the new member will be added to - /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". - public QueueAddAction(string queue, string iface) - { - this.queue = queue; - this.iface = iface; - } - - /// - /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue. - /// - /// the name of the queue the new member will be added to - /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". - /// the name of the the new member will be added to - public QueueAddAction(string queue, string iface, string memberName) - { - this.queue = queue; - this.iface = iface; - this.memberName = memberName; - } + /// + /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue. + /// + /// the name of the queue the new member will be added to + /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". + public QueueAddAction(string queue, string iface) + { + this.Queue = queue; + this.Interface = iface; + } - /// - /// Creates a new QueueAddAction that adds a new member on the given - /// interface to the given queue with the given penalty. - /// - /// the name of the queue the new member will be added to - /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". - /// the name of the the new member will be added to - /// the penalty for this member.
- /// The penalty must be a positive integer or 0 for no penalty. When calls are - /// distributed members with higher penalties are considered last. - /// - public QueueAddAction(string queue, string iface, string memberName, int penalty) - { - this.queue = queue; - this.iface = iface; - this.memberName = memberName; - this.penalty = penalty; - } - } + /// + /// Creates a new QueueAddAction that adds a new member on the given interface to the given queue. + /// + /// the name of the queue the new member will be added to + /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". + /// the name of the the new member will be added to + public QueueAddAction(string queue, string iface, string memberName) + { + this.Queue = queue; + this.Interface = iface; + this.MemberName = memberName; + } + + /// + /// Creates a new QueueAddAction that adds a new member on the given + /// interface to the given queue with the given penalty. + /// + /// the name of the queue the new member will be added to + /// Sets the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234". + /// the name of the the new member will be added to + /// + /// the penalty for this member.
+ /// The penalty must be a positive integer or 0 for no penalty. When calls are + /// distributed members with higher penalties are considered last. + /// + public QueueAddAction(string queue, string iface, string memberName, int penalty) + { + this.Queue = queue; + this.Interface = iface; + this.MemberName = memberName; + this.Penalty = penalty; + } + + /// + /// Get the name of this action, i.e. "QueueAdd". + /// + public override string Action + { + get { return "QueueAdd"; } + } + + /// + /// Get/Set the name of the queue the new member will be added to.
+ /// This property is mandatory. + ///
+ public string Queue { get; set; } + + /// + /// Get/Set the interface to add. To add a specific channel just use the channel name, e.g. "SIP/1234".
+ /// This property is mandatory. + ///
+ public string Interface { get; set; } + + /// + /// Get/Set the member to add. + /// + public string MemberName { get; set; } + + /// + /// Get/Set the penalty for this member.
+ /// The penalty must be a positive integer or 0 for no penalty. If it is not set 0 is assumed.
+ /// When calls are distributed members with higher penalties are considered last. + ///
+ public int Penalty { get; set; } + + /// + /// Get/Set if the queue member should be paused when added.
+ /// true if the queue member should be paused when added. + ///
+ public bool Paused { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueLogAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueLogAction.cs index 196cbb6..c68d01d 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueLogAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueLogAction.cs @@ -1,28 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class QueueLogAction : ManagerAction { - - private string _queue; - private string _event; - private string _uniqueid; - private string _interface; - private string _message; - /// - /// Adds custom entry in queue_log. + /// Adds custom entry in queue_log. /// public QueueLogAction() { } /// - /// Adds custom entry in queue_log. + /// Adds custom entry in queue_log. /// /// /// @@ -31,11 +19,11 @@ namespace AsterNET.Manager.Action /// public QueueLogAction(string queue, string @event, string uniqueid, string @interface, string message) { - _queue = queue; - _event = @event; - _uniqueid = uniqueid; - _interface = @interface; - _message = message; + Queue = queue; + Event = @event; + Uniqueid = uniqueid; + Interface = @interface; + Message = message; } public override string Action @@ -43,34 +31,14 @@ namespace AsterNET.Manager.Action get { return "QueueLog"; } } - public string Queue - { - get { return _queue; } - set { _queue = value; } - } + public string Queue { get; set; } - public string Event - { - get { return _event; } - set { _event = value; } - } + public string Event { get; set; } - public string Uniqueid - { - get { return _uniqueid; } - set { _uniqueid = value; } - } + public string Uniqueid { get; set; } - public string Interface - { - get { return _interface; } - set { _interface = value; } - } + public string Interface { get; set; } - public string Message - { - get { return _message; } - set { _message = value; } - } + public string Message { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePauseAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePauseAction.cs index a42be76..706fab6 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePauseAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePauseAction.cs @@ -1,112 +1,93 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The QueuePauseAction makes a queue member temporarily unavailabe (or available again).
- /// It is implemented in apps/app_queue.c
- /// Available since Asterisk 1.2. - ///
- public class QueuePauseAction : ManagerAction - { - private string iface; - private bool paused; - private string queue; + /// + /// The QueuePauseAction makes a queue member temporarily unavailabe (or available again).
+ /// It is implemented in apps/app_queue.c
+ /// Available since Asterisk 1.2. + ///
+ public class QueuePauseAction : ManagerAction + { + /// + /// Creates a new empty QueuePauseAction. + /// + public QueuePauseAction() + { + } - /// - /// Get the name of this action, i.e. "QueuePause". - /// - override public string Action - { - get - { - return "QueuePause"; - } - - } - /// - /// Get/Set the interface of the member to make available or unavailable.
- /// This property is mandatory. - ///
- public string Interface - { - get { return this.iface; } - set { this.iface = value; } - } - /// - /// Get/Set Returns the name of the queue the member is made available or unavailable on. - /// - public string Queue - { - get { return this.queue; } - set { this.queue = value; } - } - /// - /// Get/Set if the member is made available or unavailable.
- /// true to make the member unavailbale,
- /// false make the member available - ///
- public bool Paused - { - get { return this.paused; } - set { this.paused = value; } - } - - /// - /// Creates a new empty QueuePauseAction. - /// - public QueuePauseAction() - { - } - - /// - /// Creates a new QueuePauseAction that makes the member on the given - /// interface unavailable on all queues. - /// - /// the interface of the member to make unavailable - public QueuePauseAction(string iface) - { - this.iface = iface; - this.paused = true; - } - - /// - /// Creates a new QueuePauseAction that makes the member on the given - /// interface unavailable on the given queue. - /// - /// the interface of the member to make unavailable - /// the queue the member is made unvailable on - public QueuePauseAction(string iface, string queue) - { - this.iface = iface; - this.queue = queue; - this.paused = true; - } - - /// - /// Creates a new QueuePauseAction that makes the member on the given - /// interface available or unavailable on all queues. - /// - /// the interface of the member to make unavailable - /// true to make the member unavailbale, false to make the member available - public QueuePauseAction(string iface, bool paused) - { - this.iface = iface; - this.paused = paused; - } - - /// - /// Creates a new QueuePauseAction that makes the member on the given - /// interface unavailable on the given queue. - /// - /// the interface of the member to make unavailable - /// the queue the member is made unvailable on - /// true to make the member unavailbale, false to make the member available - public QueuePauseAction(string iface, string queue, bool paused) - { - this.iface = iface; - this.queue = queue; - this.paused = paused; - } - } + /// + /// Creates a new QueuePauseAction that makes the member on the given + /// interface unavailable on all queues. + /// + /// the interface of the member to make unavailable + public QueuePauseAction(string iface) + { + this.Interface = iface; + Paused = true; + } + + /// + /// Creates a new QueuePauseAction that makes the member on the given + /// interface unavailable on the given queue. + /// + /// the interface of the member to make unavailable + /// the queue the member is made unvailable on + public QueuePauseAction(string iface, string queue) + { + this.Interface = iface; + this.Queue = queue; + Paused = true; + } + + /// + /// Creates a new QueuePauseAction that makes the member on the given + /// interface available or unavailable on all queues. + /// + /// the interface of the member to make unavailable + /// true to make the member unavailbale, false to make the member available + public QueuePauseAction(string iface, bool paused) + { + this.Interface = iface; + this.Paused = paused; + } + + /// + /// Creates a new QueuePauseAction that makes the member on the given + /// interface unavailable on the given queue. + /// + /// the interface of the member to make unavailable + /// the queue the member is made unvailable on + /// true to make the member unavailbale, false to make the member available + public QueuePauseAction(string iface, string queue, bool paused) + { + this.Interface = iface; + this.Queue = queue; + this.Paused = paused; + } + + /// + /// Get the name of this action, i.e. "QueuePause". + /// + public override string Action + { + get { return "QueuePause"; } + } + + /// + /// Get/Set the interface of the member to make available or unavailable.
+ /// This property is mandatory. + ///
+ public string Interface { get; set; } + + /// + /// Get/Set Returns the name of the queue the member is made available or unavailable on. + /// + public string Queue { get; set; } + + /// + /// Get/Set if the member is made available or unavailable.
+ /// true to make the member unavailbale,
+ /// false make the member available + ///
+ public bool Paused { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePenaltyAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePenaltyAction.cs index 6d49b51..302fbc5 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePenaltyAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueuePenaltyAction.cs @@ -1,35 +1,25 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class QueuePenaltyAction : ManagerAction { - - private string _interface; - private string _penalty; - private string _queue; - /// - /// Set the penalty for a queue member. + /// Set the penalty for a queue member. /// public QueuePenaltyAction() { } /// - /// Set the penalty for a queue member. + /// Set the penalty for a queue member. /// /// /// /// public QueuePenaltyAction(string @interface, string penalty, string queue) { - _interface = @interface; - _penalty = penalty; - _queue = queue; + Interface = @interface; + Penalty = penalty; + Queue = queue; } public override string Action @@ -37,22 +27,10 @@ namespace AsterNET.Manager.Action get { return "QueuePenalty"; } } - public string Interface - { - get { return _interface; } - set { _interface = value; } - } + public string Interface { get; set; } - public string Penalty - { - get { return _penalty; } - set { _penalty = value; } - } + public string Penalty { get; set; } - public string Queue - { - get { return _queue; } - set { _queue = value; } - } + public string Queue { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueReloadAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueReloadAction.cs index 146c607..2f51aa1 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueReloadAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueReloadAction.cs @@ -1,27 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class QueueReloadAction : ManagerAction { - - private string _queue; - private string _members; - private string _rules; - private string _parameters; - /// - /// Reload a queue, queues, or any sub-section of a queue or queues. + /// Reload a queue, queues, or any sub-section of a queue or queues. /// public QueueReloadAction() { } /// - /// Reload a queue, queues, or any sub-section of a queue or queues. + /// Reload a queue, queues, or any sub-section of a queue or queues. /// /// /// @@ -29,10 +18,10 @@ namespace AsterNET.Manager.Action /// public QueueReloadAction(string queue, string members, string rules, string parameters) { - _queue = queue; - _members = members; - _rules = rules; - _parameters = parameters; + Queue = queue; + Members = members; + Rules = rules; + Parameters = parameters; } public override string Action @@ -40,28 +29,12 @@ namespace AsterNET.Manager.Action get { return "QueueReload"; } } - public string Queue - { - get { return _queue; } - set { _queue = value; } - } + public string Queue { get; set; } - public string Members - { - get { return _members; } - set { _members = value; } - } + public string Members { get; set; } - public string Rules - { - get { return _rules; } - set { _rules = value; } - } + public string Rules { get; set; } - public string Parameters - { - get { return _parameters; } - set { _parameters = value; } - } + public string Parameters { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRemoveAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRemoveAction.cs index 9e17a03..93a5f2f 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRemoveAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRemoveAction.cs @@ -1,62 +1,46 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The QueueRemoveAction removes a member from a queue.
- /// It is implemented in apps/app_queue.c - ///
- public class QueueRemoveAction : ManagerAction - { - /// The name of the queue the member will be removed from. - private string queue; - private string iface; + /// + /// The QueueRemoveAction removes a member from a queue.
+ /// It is implemented in apps/app_queue.c + ///
+ public class QueueRemoveAction : ManagerAction + { + /// + /// Creates a new empty QueueRemoveAction. + /// + public QueueRemoveAction() + { + } - /// - /// Get the name of this action, i.e. "QueueRemove". - /// - override public string Action - { - get - { - return "QueueRemove"; - } - - } - /// - /// Get/Set the name of the queue the member will be removed from. - /// - public string Queue - { - get { return this.queue; } - set { this.queue = value; } - } - /// - /// Get/Set the interface to remove.
- /// This property is mandatory. - ///
- public string Interface - { - get { return this.iface; } - set { this.iface = value; } - } - - /// - /// Creates a new empty QueueRemoveAction. - /// - public QueueRemoveAction() - { - } - - /// - /// Creates a new QueueRemoveAction that removes the member on the given interface from the given queue. - /// - /// the name of the queue the member will be removed from - /// the interface of the member to remove - public QueueRemoveAction(string queue, string iface) - { - this.queue = queue; - this.iface = iface; - } - } + /// + /// Creates a new QueueRemoveAction that removes the member on the given interface from the given queue. + /// + /// the name of the queue the member will be removed from + /// the interface of the member to remove + public QueueRemoveAction(string queue, string iface) + { + this.Queue = queue; + this.Interface = iface; + } + + /// + /// Get the name of this action, i.e. "QueueRemove". + /// + public override string Action + { + get { return "QueueRemove"; } + } + + /// + /// Get/Set the name of the queue the member will be removed from. + /// + public string Queue { get; set; } + + /// + /// Get/Set the interface to remove.
+ /// This property is mandatory. + ///
+ public string Interface { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueResetAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueResetAction.cs index 91e01b1..a7c54bc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueResetAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueResetAction.cs @@ -1,29 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class QueueResetAction : ManagerAction { - - private string _queue; - /// - /// Reset queue statistics. + /// Reset queue statistics. /// public QueueResetAction() { } /// - /// Reset queue statistics. + /// Reset queue statistics. /// /// public QueueResetAction(string queue) { - _queue = queue; + Queue = queue; } public override string Action @@ -31,10 +23,6 @@ namespace AsterNET.Manager.Action get { return "QueueReset"; } } - public string Queue - { - get { return _queue; } - set { _queue = value; } - } + public string Queue { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRuleAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRuleAction.cs index 55e1cf9..43c284c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRuleAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueRuleAction.cs @@ -1,22 +1,14 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace AsterNET.Manager.Action +namespace AsterNET.Manager.Action { public class QueueRuleAction : ManagerAction { - - private string _rule; - public QueueRuleAction() { } public QueueRuleAction(string rule) { - _rule = rule; + Rule = rule; } public override string Action @@ -24,10 +16,6 @@ namespace AsterNET.Manager.Action get { return "QueueRule"; } } - public string Rule - { - get { return _rule; } - set { _rule = value; } - } + public string Rule { get; set; } } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueStatusAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueStatusAction.cs index ebbfe85..4e77ab2 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/QueueStatusAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/QueueStatusAction.cs @@ -1,65 +1,63 @@ using System; +using AsterNET.Manager.Event; + namespace AsterNET.Manager.Action { - /// - /// The QueueStatusAction requests the state of all defined queues their members (agents) and entries (callers).
- /// For each queue a QueueParamsEvent is generated, followed by a - /// QueueMemberEvent for each member of that queue and a QueueEntryEvent for each - /// entry in the queue.
- /// Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of the generated dump.
- /// This action is implemented in apps/app_queue.c - ///
- /// - /// - /// - /// - public class QueueStatusAction : ManagerActionEvent - { - private string queue; - private string member; + /// + /// The QueueStatusAction requests the state of all defined queues their members (agents) and entries (callers).
+ /// For each queue a QueueParamsEvent is generated, followed by a + /// QueueMemberEvent for each member of that queue and a QueueEntryEvent for each + /// entry in the queue.
+ /// Since Asterisk 1.2 a QueueStatusCompleteEvent is sent to denote the end of the generated dump.
+ /// This action is implemented in apps/app_queue.c + ///
+ /// + /// + /// + /// + public class QueueStatusAction : ManagerActionEvent + { + #region Action - #region Action - /// - /// Get the name of this action, i.e. "QueueStatus". - /// - public override string Action - { - get { return "QueueStatus"; } - } - #endregion - #region Queue - /// - /// Get/Set the queue filter. - /// - public string Queue - { - get { return queue; } - set { this.queue = value; } - } - #endregion - #region Member - /// - /// Get/Set the member filter. - /// - public string Member - { - get { return member; } - set { this.member = value; } - } - #endregion + /// + /// Get the name of this action, i.e. "QueueStatus". + /// + public override string Action + { + get { return "QueueStatus"; } + } - #region ActionCompleteEventClass - public override Type ActionCompleteEventClass() - { - return typeof(Event.QueueStatusCompleteEvent); - } - #endregion + #endregion - #region QueueStatusAction() - /// Creates a new QueueStatusAction. - public QueueStatusAction() - { - } - #endregion - } + #region Queue + + /// + /// Get/Set the queue filter. + /// + public string Queue { get; set; } + + #endregion + + #region Member + + /// + /// Get/Set the member filter. + /// + public string Member { get; set; } + + #endregion + + #region ActionCompleteEventClass + + public override Type ActionCompleteEventClass() + { + return typeof (QueueStatusCompleteEvent); + } + + #endregion + + #region QueueStatusAction() + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/RedirectAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/RedirectAction.cs index 0500892..7a0d96c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/RedirectAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/RedirectAction.cs @@ -1,102 +1,79 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// Redirects a given channel (and an optional additional channel) to a new extension. - /// - public class RedirectAction : ManagerAction - { - private string channel; - private string extraChannel; - private string exten; - private string context; - private int priority; + /// + /// Redirects a given channel (and an optional additional channel) to a new extension. + /// + public class RedirectAction : ManagerAction + { + /// + /// Creates a new empty RedirectAction. + /// + public RedirectAction() + { + } - /// - /// Get the name of this action, i.e. "Redirect". - /// - override public string Action - { - get { return "Redirect"; } - } - /// - /// Get/Set name of the channel to redirect. - public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - /// - /// Get/Set the name of the additional channel to redirect. - /// - public string ExtraChannel - { - get { return this.extraChannel; } - set { this.extraChannel = value; } - } - /// - /// Get/Set the destination context. - /// - public string Context - { - get { return this.context; } - set { this.context = value; } - } - /// - /// Get/Set the destination extension. - /// - public string Exten - { - get { return this.exten; } - set { this.exten = value; } - } - /// - /// Get/Set the destination priority. - /// - public int Priority - { - get { return this.priority; } - set { this.priority = value; } - } - - /// - /// Creates a new empty RedirectAction. - /// - public RedirectAction() - { - } + /// + /// Creates a new RedirectAction that redirects the given channel to the given context, extension, priority triple. + /// + /// the name of the channel to redirect + /// the destination context + /// the destination extension + /// the destination priority + public RedirectAction(string channel, string context, string exten, int priority) + { + this.Channel = channel; + this.Context = context; + this.Exten = exten; + this.Priority = priority; + } - /// - /// Creates a new RedirectAction that redirects the given channel to the given context, extension, priority triple. - /// - /// the name of the channel to redirect - /// the destination context - /// the destination extension - /// the destination priority - public RedirectAction(string channel, string context, string exten, int priority) - { - this.channel = channel; - this.context = context; - this.exten = exten; - this.priority = priority; - } - - /// - /// Creates a new RedirectAction that redirects the given channels to the given context, extension, priority triple. - /// - /// the name of the first channel to redirect - /// the name of the second channel to redirect - /// the destination context - /// the destination extension - /// the destination priority - public RedirectAction(string channel, string extraChannel, string context, string exten, int priority) - { - this.channel = channel; - this.extraChannel = extraChannel; - this.context = context; - this.exten = exten; - this.priority = priority; - } - } + /// + /// Creates a new RedirectAction that redirects the given channels to the given context, extension, priority triple. + /// + /// the name of the first channel to redirect + /// the name of the second channel to redirect + /// the destination context + /// the destination extension + /// the destination priority + public RedirectAction(string channel, string extraChannel, string context, string exten, int priority) + { + this.Channel = channel; + this.ExtraChannel = extraChannel; + this.Context = context; + this.Exten = exten; + this.Priority = priority; + } + + /// + /// Get the name of this action, i.e. "Redirect". + /// + public override string Action + { + get { return "Redirect"; } + } + + /// + /// Get/Set name of the channel to redirect. + public string Channel { get; set; } + + /// + /// Get/Set the name of the additional channel to redirect. + /// + public string ExtraChannel { get; set; } + + /// + /// Get/Set the destination context. + /// + public string Context { get; set; } + + /// + /// Get/Set the destination extension. + /// + public string Exten { get; set; } + + /// + /// Get/Set the destination priority. + /// + public int Priority { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/SIPPeersAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/SIPPeersAction.cs index 9501d05..1ab6e88 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/SIPPeersAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/SIPPeersAction.cs @@ -1,31 +1,26 @@ using System; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// Retrieves a list of all defined SIP peers.
- /// For each peer that is found a PeerEntryEvent is sent by Asterisk containing - /// the details. When all peers have been reported a PeerlistCompleteEvent is sent.
- /// Available since Asterisk 1.2 - ///
- /// - /// - public class SIPPeersAction : ManagerActionEvent - { - public override string Action - { - get { return "SIPPeers"; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.PeerlistCompleteEvent); - } - - /// - /// Creates a new SIPPeersAction. - /// - public SIPPeersAction() - { - } - } + /// + /// Retrieves a list of all defined SIP peers.
+ /// For each peer that is found a PeerEntryEvent is sent by Asterisk containing + /// the details. When all peers have been reported a PeerlistCompleteEvent is sent.
+ /// Available since Asterisk 1.2 + ///
+ /// + /// + public class SIPPeersAction : ManagerActionEvent + { + public override string Action + { + get { return "SIPPeers"; } + } + + public override Type ActionCompleteEventClass() + { + return typeof (PeerlistCompleteEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/SIPShowPeerAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/SIPShowPeerAction.cs index 601a055..5b584a9 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/SIPShowPeerAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/SIPShowPeerAction.cs @@ -1,48 +1,45 @@ using System; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// Retrieves a the details about a given SIP peer.
- /// For a PeerEntryEvent is sent by Asterisk containing the details of the peer - /// followed by a PeerlistCompleteEvent.
- /// Available since Asterisk 1.2 - ///
- /// - /// - public class SIPShowPeerAction : ManagerActionEvent - { - private string peer; + /// + /// Retrieves a the details about a given SIP peer.
+ /// For a PeerEntryEvent is sent by Asterisk containing the details of the peer + /// followed by a PeerlistCompleteEvent.
+ /// Available since Asterisk 1.2 + ///
+ /// + /// + public class SIPShowPeerAction : ManagerActionEvent + { + /// Creates a new empty SIPShowPeerAction. + public SIPShowPeerAction() + { + } - override public string Action - { - get { return "SIPShowPeer"; } - } - /// - /// Get/Set the name of the peer to retrieve.
- /// This parameter is mandatory. - ///
- public string Peer - { - get { return this.peer; } - set { this.peer = value; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.PeerlistCompleteEvent); - } - - /// Creates a new empty SIPShowPeerAction. - public SIPShowPeerAction() - { - } - - /// - /// Creates a new SIPShowPeerAction that requests the details about the given SIP peer. - /// - public SIPShowPeerAction(string peer) - { - this.peer = peer; - } - } + /// + /// Creates a new SIPShowPeerAction that requests the details about the given SIP peer. + /// + public SIPShowPeerAction(string peer) + { + this.Peer = peer; + } + + public override string Action + { + get { return "SIPShowPeer"; } + } + + /// + /// Get/Set the name of the peer to retrieve.
+ /// This parameter is mandatory. + ///
+ public string Peer { get; set; } + + public override Type ActionCompleteEventClass() + { + return typeof (PeerlistCompleteEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/SetCDRUserFieldAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/SetCDRUserFieldAction.cs index 915b11e..baa5514 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/SetCDRUserFieldAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/SetCDRUserFieldAction.cs @@ -1,81 +1,70 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The SetCDRUserFieldAction causes the user field of the call detail record for the given channel to be changed.
- /// Depending on the value of the append property the value is appended or overwritten.
- /// The SetCDRUserFieldAction is implemented in apps/app_setcdruserfield.c - ///
- public class SetCDRUserFieldAction : ManagerAction - { - private string channel; - private string userField; - private bool append; + /// + /// The SetCDRUserFieldAction causes the user field of the call detail record for the given channel to be changed. + ///
+ /// Depending on the value of the append property the value is appended or overwritten.
+ /// The SetCDRUserFieldAction is implemented in apps/app_setcdruserfield.c + ///
+ public class SetCDRUserFieldAction : ManagerAction + { + /// + /// Creates a new empty SetCDRUserFieldAction. + /// + public SetCDRUserFieldAction() + { + } - /// - /// Get the name of the action, i.e. "SetCDRUserField". - /// - override public string Action - { - get { return "SetCDRUserField"; } - } - /// - /// Get/Set the name of the channel to set the cdr user field on.
- /// This property is mandatory. - ///
- public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - /// - /// Get/Set the value of the cdr user field to set or append.
- /// This property is mandatory. - ///
- public string UserField - { - get { return this.userField; } - set { this.userField = value; } - } - /// - /// Get/Set if the value of the cdr user field is appended or overwritten.
- /// true to append the value to the cdr user field or false to overwrite. - ///
- public bool Append - { - get { return this.append; } - set { this.append = value; } - } - /// - /// Creates a new empty SetCDRUserFieldAction. - /// - public SetCDRUserFieldAction() - { - } - - /// - /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the given value. - /// - /// the name of the channel - /// the new value of the userfield - public SetCDRUserFieldAction(string channel, string userField) - { - this.channel = channel; - this.userField = userField; - } - - /// - /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the given value. - /// - /// the name of the channel - /// the new value of the userfield - /// true to append the value to the cdr user field or false to overwrite - public SetCDRUserFieldAction(string channel, string userField, bool append) - { - this.channel = channel; - this.userField = userField; - this.append = append; - } - } + /// + /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the + /// given value. + /// + /// the name of the channel + /// the new value of the userfield + public SetCDRUserFieldAction(string channel, string userField) + { + this.Channel = channel; + this.UserField = userField; + } + + /// + /// Creates a new SetCDRUserFieldAction that sets the user field of the call detail record for the given channel to the + /// given value. + /// + /// the name of the channel + /// the new value of the userfield + /// true to append the value to the cdr user field or false to overwrite + public SetCDRUserFieldAction(string channel, string userField, bool append) + { + this.Channel = channel; + this.UserField = userField; + this.Append = append; + } + + /// + /// Get the name of the action, i.e. "SetCDRUserField". + /// + public override string Action + { + get { return "SetCDRUserField"; } + } + + /// + /// Get/Set the name of the channel to set the cdr user field on.
+ /// This property is mandatory. + ///
+ public string Channel { get; set; } + + /// + /// Get/Set the value of the cdr user field to set or append.
+ /// This property is mandatory. + ///
+ public string UserField { get; set; } + + /// + /// Get/Set if the value of the cdr user field is appended or overwritten.
+ /// true to append the value to the cdr user field or false to overwrite. + ///
+ public bool Append { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/SetVarAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/SetVarAction.cs index 56edac7..30f3389 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/SetVarAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/SetVarAction.cs @@ -1,81 +1,84 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The SetVar action sets the value of a channel variable for a given channel. - /// - public class SetVarAction : ManagerAction - { - /// The channel on which to set the variable. - public string channel; - /// The name of the variable to set. - public string varName; - /// The value to store. - public string varValue; + /// + /// The SetVar action sets the value of a channel variable for a given channel. + /// + public class SetVarAction : ManagerAction + { + /// The channel on which to set the variable. + public string channel; - /// - /// Get the name of this action, i.e. "SetVar". - /// - override public string Action - { - get { return "SetVar"; } - } - /// - /// Get/Set the name of the channel. - /// - public string Channel - { - get { return channel; } - set { this.channel = value; } - } - /// - /// Get/Set the name of the variable to set. - /// - public string Variable - { - get { return this.varName; } - set { this.varName = value; } - } - /// - /// Get/Set the value to store. - /// - public string Value - { - get { return this.varValue; } - set { this.varValue = value; } - } - - /// - /// Creates a new empty SetVarAction. - /// - public SetVarAction() - { - } + /// The name of the variable to set. + public string varName; - /// - /// Creates a new SetVarAction that sets the given global variable to a new value. - /// - /// the name of the global variable to set - /// the new value - public SetVarAction(string variable, string value) - { - this.varName = variable; - this.varValue = value; - } + /// The value to store. + public string varValue; - /// - /// Creates a new SetVarAction that sets the given channel variable of the - /// given channel to a new value. - /// - /// the name of the channel to set the variable on - /// the name of the channel variable - /// the new value - public SetVarAction(string channel, string variable, string value) - { - this.channel = channel; - this.varName = variable; - this.varValue = value; - } - } + /// + /// Creates a new empty SetVarAction. + /// + public SetVarAction() + { + } + + /// + /// Creates a new SetVarAction that sets the given global variable to a new value. + /// + /// the name of the global variable to set + /// the new value + public SetVarAction(string variable, string value) + { + varName = variable; + varValue = value; + } + + /// + /// Creates a new SetVarAction that sets the given channel variable of the + /// given channel to a new value. + /// + /// the name of the channel to set the variable on + /// the name of the channel variable + /// the new value + public SetVarAction(string channel, string variable, string value) + { + this.channel = channel; + varName = variable; + varValue = value; + } + + /// + /// Get the name of this action, i.e. "SetVar". + /// + public override string Action + { + get { return "SetVar"; } + } + + /// + /// Get/Set the name of the channel. + /// + public string Channel + { + get { return channel; } + set { channel = value; } + } + + /// + /// Get/Set the name of the variable to set. + /// + public string Variable + { + get { return varName; } + set { varName = value; } + } + + /// + /// Get/Set the value to store. + /// + public string Value + { + get { return varValue; } + set { varValue = value; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/StatusAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/StatusAction.cs index 6a4dc8b..e013ddc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/StatusAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/StatusAction.cs @@ -1,33 +1,28 @@ using System; +using AsterNET.Manager.Event; namespace AsterNET.Manager.Action { - /// - /// The StatusAction requests the state of all active channels.
- /// For each active channel a StatusEvent is generated. After the state of all - /// channels has been reported a StatusCompleteEvent is generated. - ///
- /// - /// - public class StatusAction : ManagerActionEvent - { - /// - /// Get the name of this action, i.e. "Status". - /// - public override string Action - { - get { return "Status"; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.StatusCompleteEvent); - } - - /// - /// Creates a new StatusAction. - /// - public StatusAction() - { - } - } + /// + /// The StatusAction requests the state of all active channels.
+ /// For each active channel a StatusEvent is generated. After the state of all + /// channels has been reported a StatusCompleteEvent is generated. + ///
+ /// + /// + public class StatusAction : ManagerActionEvent + { + /// + /// Get the name of this action, i.e. "Status". + /// + public override string Action + { + get { return "Status"; } + } + + public override Type ActionCompleteEventClass() + { + return typeof (StatusCompleteEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/StopMonitorAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/StopMonitorAction.cs index 23701c6..3f581a2 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/StopMonitorAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/StopMonitorAction.cs @@ -1,53 +1,54 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The StopMonitorAction ends monitoring (recording) a channel.
- /// It is implemented in res/res_monitor.c - ///
- public class StopMonitorAction : ManagerAction - { - /// The name of the channel to end monitoring. - private string channel; + /// + /// The StopMonitorAction ends monitoring (recording) a channel.
+ /// It is implemented in res/res_monitor.c + ///
+ public class StopMonitorAction : ManagerAction + { + #region Action - #region Action - /// - /// Get the name of this action, i.e. "StopMonitor". - /// - override public string Action - { - get { return "StopMonitor"; } - } - #endregion - #region Channel - /// - /// Get/Set the name of the channel to end monitoring.
- /// This property is mandatory. - ///
- public string Channel - { - get { return this.channel; } - set { this.channel = value; } - } - #endregion - - #region StopMonitorAction() - /// - /// Creates a new empty StopMonitorAction. - /// - public StopMonitorAction() - { - } - #endregion - #region StopMonitorAction(string channel) - /// - /// Creates a new StopMonitorAction that ends monitoring of the given channel. - /// - public StopMonitorAction(string channel) - { - this.channel = channel; - } - #endregion - } + /// + /// Get the name of this action, i.e. "StopMonitor". + /// + public override string Action + { + get { return "StopMonitor"; } + } + + #endregion + + #region Channel + + /// + /// Get/Set the name of the channel to end monitoring.
+ /// This property is mandatory. + ///
+ public string Channel { get; set; } + + #endregion + + #region StopMonitorAction() + + /// + /// Creates a new empty StopMonitorAction. + /// + public StopMonitorAction() + { + } + + #endregion + + #region StopMonitorAction(string channel) + + /// + /// Creates a new StopMonitorAction that ends monitoring of the given channel. + /// + public StopMonitorAction(string channel) + { + this.Channel = channel; + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/UpdateConfigAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/UpdateConfigAction.cs index daf1c65..e946169 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/UpdateConfigAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/UpdateConfigAction.cs @@ -1,198 +1,185 @@ -using System; -using AsterNET.Manager.Response; using System.Collections.Generic; +using AsterNET.Manager.Response; namespace AsterNET.Manager.Action { - /// - /// The UpdateConfigAction sends an UpdateConfig command to the asterisk server. - /// Please take note that unlike the manager documentation, this command does not - /// dump back the config file upon success -- it only tells you it succeeded. You - /// should use the handy addCommand method this class provides for specifying - /// what actions you would like to take on the configuration file. It will - /// generate appropriate sequence numbers for the command. You may use the static - /// ACTION_* fields provided by this action to specify what action you would like - /// to take, while avoiding handling the strings required. Plain fields:
- /// SrcFilename: Configuration filename to read(e.g. foo.conf)
- /// DstFilename: Configuration filename to write(e.g. foo.conf)
- /// Reload: Whether or not a reload should take place (or name of specific module)
- /// Repeatable fields:
- /// Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
- /// Cat-XXXXXX: Category to operate on
- /// Var-XXXXXX: Variable to work on
- /// Value-XXXXXX: Value to work on
- /// Match-XXXXXX: Extra match required to match line - ///
- public class UpdateConfigAction : ManagerActionResponse - { - public const string ACTION_NEWCAT = "newcat"; - public const string ACTION_RENAMECAT = "renamecat"; - public const string ACTION_DELCAT = "delcat"; - public const string ACTION_UPDATE = "update"; - public const string ACTION_DELETE = "delete"; - public const string ACTION_APPEND = "append"; + /// + /// The UpdateConfigAction sends an UpdateConfig command to the asterisk server. + /// Please take note that unlike the manager documentation, this command does not + /// dump back the config file upon success -- it only tells you it succeeded. You + /// should use the handy addCommand method this class provides for specifying + /// what actions you would like to take on the configuration file. It will + /// generate appropriate sequence numbers for the command. You may use the static + /// ACTION_* fields provided by this action to specify what action you would like + /// to take, while avoiding handling the strings required. Plain fields:
+ /// SrcFilename: Configuration filename to read(e.g. foo.conf)
+ /// DstFilename: Configuration filename to write(e.g. foo.conf)
+ /// Reload: Whether or not a reload should take place (or name of specific module)
+ /// Repeatable fields:
+ /// Action-XXXXXX: Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append)
+ /// Cat-XXXXXX: Category to operate on
+ /// Var-XXXXXX: Variable to work on
+ /// Value-XXXXXX: Value to work on
+ /// Match-XXXXXX: Extra match required to match line + ///
+ public class UpdateConfigAction : ManagerActionResponse + { + public const string ACTION_NEWCAT = "newcat"; + public const string ACTION_RENAMECAT = "renamecat"; + public const string ACTION_DELCAT = "delcat"; + public const string ACTION_UPDATE = "update"; + public const string ACTION_DELETE = "delete"; + public const string ACTION_APPEND = "append"; - private string reload; - private string srcFileName; - private string dstFileName; - private int actionCounter; - private Dictionary actions; + private readonly Dictionary actions; + private int actionCounter; - /// - /// Creates a new UpdateConfigAction. - /// - public UpdateConfigAction() - : base() - { - actionCounter = 0; - actions = new Dictionary(); - } + /// + /// Creates a new UpdateConfigAction. + /// + public UpdateConfigAction() + { + actionCounter = 0; + actions = new Dictionary(); + } - /// - /// Creates a new UpdateConfigAction. - /// - public UpdateConfigAction(string srcFilename, string dstFilename, string reload) - : this() - { - this.srcFileName = srcFilename; - this.dstFileName = dstFilename; - this.reload = reload; - } + /// + /// Creates a new UpdateConfigAction. + /// + public UpdateConfigAction(string srcFilename, string dstFilename, string reload) + : this() + { + SrcFileName = srcFilename; + DstFileName = dstFilename; + this.Reload = reload; + } - /// - /// Creates a new UpdateConfigAction. - /// - public UpdateConfigAction(string srcFilename, string dstFilename, bool reload) - : this() - { - this.srcFileName = srcFilename; - this.dstFileName = dstFilename; - this.reload = (reload ? "true" : ""); - } + /// + /// Creates a new UpdateConfigAction. + /// + public UpdateConfigAction(string srcFilename, string dstFilename, bool reload) + : this() + { + SrcFileName = srcFilename; + DstFileName = dstFilename; + this.Reload = (reload ? "true" : ""); + } - /// - /// Creates a new UpdateConfigAction. - /// - public UpdateConfigAction(string srcFilename, string dstFilename) - : this() - { - this.srcFileName = srcFilename; - this.dstFileName = dstFilename; - this.reload = ""; - } + /// + /// Creates a new UpdateConfigAction. + /// + public UpdateConfigAction(string srcFilename, string dstFilename) + : this() + { + SrcFileName = srcFilename; + DstFileName = dstFilename; + Reload = ""; + } - /// - /// Get/Set the destination filename. - /// - public string DstFileName - { - get { return dstFileName; } - set { dstFileName = value; } - } - - /// - /// Get/Set the source filename. - /// - public string SrcFileName - { - get { return srcFileName; } - set { srcFileName = value; } - } - - /// - /// Get/Set the reload behavior of this action (yes), or sets a specific module (name) to be reloaded.
- /// Set to empty string to update without reload. - ///
- public string Reload - { - get { return reload; } - set { reload = value; } - } + /// + /// Get/Set the destination filename. + /// + public string DstFileName { get; set; } - /// - /// Get the name of this action. - /// - public override string Action - { - get { return "UpdateConfig"; } - } + /// + /// Get/Set the source filename. + /// + public string SrcFileName { get; set; } - #region AddCommand(...) - /// - /// Adds a command to update a config file while sparing you the details of - /// the Manager's required syntax. If you want to omit one of the command's - /// sections, provide a null value to this method. The command index will be - /// incremented even if you supply a null for all parameters, though the action - /// will be unaffected. - /// - /// Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append) - /// Category to operate on - /// Variable to work on - /// Value to work on - /// Extra match required to match line - public void AddCommand(string action, string category, string variable, string value, string match) - { - var i = actionCounter++; + /// + /// Get/Set the reload behavior of this action (yes), or sets a specific module (name) to be reloaded.
+ /// Set to empty string to update without reload. + ///
+ public string Reload { get; set; } + + /// + /// Get the name of this action. + /// + public override string Action + { + get { return "UpdateConfig"; } + } + + #region AddCommand(...) + + /// + /// Adds a command to update a config file while sparing you the details of + /// the Manager's required syntax. If you want to omit one of the command's + /// sections, provide a null value to this method. The command index will be + /// incremented even if you supply a null for all parameters, though the action + /// will be unaffected. + /// + /// Action to Take (NewCat,RenameCat,DelCat,Update,Delete,Append) + /// Category to operate on + /// Variable to work on + /// Value to work on + /// Extra match required to match line + public void AddCommand(string action, string category, string variable, string value, string match) + { + var i = actionCounter++; var index = i.ToString().PadLeft(6, '0'); - if (!string.IsNullOrEmpty(action)) + if (!string.IsNullOrEmpty(action)) actions.Add("Action-" + index, action); - if (!string.IsNullOrEmpty(category)) + if (!string.IsNullOrEmpty(category)) actions.Add("Cat-" + index, category); - if (!string.IsNullOrEmpty(variable)) + if (!string.IsNullOrEmpty(variable)) actions.Add("Var-" + index, variable); - if (!string.IsNullOrEmpty(value)) + if (!string.IsNullOrEmpty(value)) actions.Add("Value-" + index, value); - if (!string.IsNullOrEmpty(match)) + if (!string.IsNullOrEmpty(match)) actions.Add("Match-" + index, match); - } + } - public void AddCommand(string action, string category, string variable, string value) - { - AddCommand(action, category, variable, value, null); - } + public void AddCommand(string action, string category, string variable, string value) + { + AddCommand(action, category, variable, value, null); + } - public void AddCommand(string action, string category, string variable) - { - AddCommand(action, category, variable, null, null); - } + public void AddCommand(string action, string category, string variable) + { + AddCommand(action, category, variable, null, null); + } - public void AddCommand(string action, string category) - { - AddCommand(action, category, null, null, null); - } + public void AddCommand(string action, string category) + { + AddCommand(action, category, null, null, null); + } - public void AddCommand(string action) - { - AddCommand(action, null, null, null, null); - } + public void AddCommand(string action) + { + AddCommand(action, null, null, null, null); + } - public void AddCommand() - { - AddCommand(null, null, null, null, null); - } - #endregion + public void AddCommand() + { + AddCommand(null, null, null, null, null); + } - #region Actions - /// - /// Dictionary of the action's desired operations where Map keys contain:
- /// action,cat,var,value,match pairs followed by -XXXXXX, and the values contain the values for those keys. - /// This method will typically only be used by the ActionBuilder to generate the actual strings to be sent to the manager interface. - ///
- public Dictionary Actions - { - get { return actions; } - } - #endregion + #endregion - public override object ActionCompleteResponseClass() - { - return new ManagerResponse(); - } + #region Actions - } -} + /// + /// Dictionary of the action's desired operations where Map keys contain:
+ /// action,cat,var,value,match pairs followed by -XXXXXX, and the values contain the values for those keys. + /// This method will typically only be used by the ActionBuilder to generate the actual strings to be sent to the + /// manager interface. + ///
+ public Dictionary Actions + { + get { return actions; } + } + + #endregion + + public override object ActionCompleteResponseClass() + { + return new ManagerResponse(); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOffAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOffAction.cs index 56542bf..a5b402d 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOffAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOffAction.cs @@ -1,42 +1,37 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off. - /// - public class ZapDNDOffAction : ManagerAction - { - private int zapChannel; + /// + /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status off. + /// + public class ZapDNDOffAction : ManagerAction + { + /// + /// Creates a new empty ZapDNDOffAction. + /// + public ZapDNDOffAction() + { + } - /// - /// Get the name of this action, i.e. "ZapDNDOff". - /// - override public string Action - { - get { return "ZapDNDOff"; } - } - /// - /// Get/Set the number of the zap channel to switch to dnd off.
- /// This property is mandatory. - ///
- public int ZapChannel - { - get { return this.zapChannel; } - set { this.zapChannel = value; } - } - /// - /// Creates a new empty ZapDNDOffAction. - /// - public ZapDNDOffAction() - { - } - /// - /// Creates a new ZapDNDOffAction that disables "Do Not Disturb" status for the given zap channel. - /// - public ZapDNDOffAction(int zapChannel) - { - this.zapChannel = zapChannel; - } - } + /// + /// Creates a new ZapDNDOffAction that disables "Do Not Disturb" status for the given zap channel. + /// + public ZapDNDOffAction(int zapChannel) + { + this.ZapChannel = zapChannel; + } + + /// + /// Get the name of this action, i.e. "ZapDNDOff". + /// + public override string Action + { + get { return "ZapDNDOff"; } + } + + /// + /// Get/Set the number of the zap channel to switch to dnd off.
+ /// This property is mandatory. + ///
+ public int ZapChannel { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOnAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOnAction.cs index 22e875d..1df348e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOnAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDNDOnAction.cs @@ -1,43 +1,37 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on. - /// - public class ZapDNDOnAction : ManagerAction - { - private int zapChannel; + /// + /// The ZapDNDOnAction switches a zap channel "Do Not Disturb" status on. + /// + public class ZapDNDOnAction : ManagerAction + { + /// + /// Creates a new empty ZapDNDOnAction. + /// + public ZapDNDOnAction() + { + } - /// - /// Get the name of this action, i.e. "ZapDNDOn". - /// - override public string Action - { - get { return "ZapDNDOn"; } - } - /// - /// Get/Set the number of the zap channel to switch to dnd on.
- /// This property is mandatory. - ///
- public int ZapChannel - { - get { return this.zapChannel; } - set { this.zapChannel = value; } - } - /// - /// Creates a new empty ZapDNDOnAction. - /// - public ZapDNDOnAction() - { - } - - /// - /// Creates a new ZapDNDOnAction that enables "Do Not Disturb" status for the given zap channel. - /// - public ZapDNDOnAction(int zapChannel) - { - this.zapChannel = zapChannel; - } - } + /// + /// Creates a new ZapDNDOnAction that enables "Do Not Disturb" status for the given zap channel. + /// + public ZapDNDOnAction(int zapChannel) + { + this.ZapChannel = zapChannel; + } + + /// + /// Get the name of this action, i.e. "ZapDNDOn". + /// + public override string Action + { + get { return "ZapDNDOn"; } + } + + /// + /// Get/Set the number of the zap channel to switch to dnd on.
+ /// This property is mandatory. + ///
+ public int ZapChannel { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDialOffhookAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDialOffhookAction.cs index e2deca0..eb38826 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDialOffhookAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapDialOffhookAction.cs @@ -1,53 +1,42 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ZapDialOffhookAction dials a number on a zap channel while offhook. - /// - public class ZapDialOffhookAction : ManagerAction - { - private int zapChannel; - private string number; + /// + /// The ZapDialOffhookAction dials a number on a zap channel while offhook. + /// + public class ZapDialOffhookAction : ManagerAction + { + /// Creates a new empty ZapDialOffhookAction. + public ZapDialOffhookAction() + { + } - /// - /// Get the name of this action, i.e. "ZapDialOffhook". - /// - override public string Action - { - get { return "ZapDialOffhook"; } - } - /// - /// Get/Set the number of the zap channel.
- /// This property is mandatory. - ///
- public int ZapChannel - { - get { return this.zapChannel; } - set { this.zapChannel = value; } - } - /// - /// Get/Set the number to dial.
- /// This property is mandatory. - ///
- public string Number - { - get { return this.number; } - set { this.number = value; } - } - - /// Creates a new empty ZapDialOffhookAction. - public ZapDialOffhookAction() - { - } - - /// - /// Creates a new ZapDialOffhookAction that dials the given number on the given zap channel. - /// - public ZapDialOffhookAction(int zapChannel, string number) - { - this.zapChannel = zapChannel; - this.number = number; - } - } + /// + /// Creates a new ZapDialOffhookAction that dials the given number on the given zap channel. + /// + public ZapDialOffhookAction(int zapChannel, string number) + { + this.ZapChannel = zapChannel; + this.Number = number; + } + + /// + /// Get the name of this action, i.e. "ZapDialOffhook". + /// + public override string Action + { + get { return "ZapDialOffhook"; } + } + + /// + /// Get/Set the number of the zap channel.
+ /// This property is mandatory. + ///
+ public int ZapChannel { get; set; } + + /// + /// Get/Set the number to dial.
+ /// This property is mandatory. + ///
+ public string Number { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapHangupAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapHangupAction.cs index 7065e1c..18892fc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapHangupAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapHangupAction.cs @@ -1,44 +1,37 @@ -using System; - namespace AsterNET.Manager.Action { - /// - /// The ZapHangupAction hangs up a zap channel. - /// - public class ZapHangupAction : ManagerAction - { - private int zapChannel; + /// + /// The ZapHangupAction hangs up a zap channel. + /// + public class ZapHangupAction : ManagerAction + { + /// + /// Creates a new empty ZapHangupAction. + /// + public ZapHangupAction() + { + } - /// - /// Get the name of this action, i.e. "ZapHangup". - /// - override public string Action - { - get { return "ZapHangup"; } - } - /// - /// Get/Set the number of the zap channel to hangup.
- /// This property is mandatory. - ///
- public int ZapChannel - { - get { return this.zapChannel; } - set { this.zapChannel = value; } - } - - /// - /// Creates a new empty ZapHangupAction. - /// - public ZapHangupAction() - { - } - - /// - /// Creates a new ZapHangupAction that hangs up the given zap channel (the number of the zap channel to hang up). - /// - public ZapHangupAction(int zapChannel) - { - this.zapChannel = zapChannel; - } - } + /// + /// Creates a new ZapHangupAction that hangs up the given zap channel (the number of the zap channel to hang up). + /// + public ZapHangupAction(int zapChannel) + { + this.ZapChannel = zapChannel; + } + + /// + /// Get the name of this action, i.e. "ZapHangup". + /// + public override string Action + { + get { return "ZapHangup"; } + } + + /// + /// Get/Set the number of the zap channel to hangup.
+ /// This property is mandatory. + ///
+ public int ZapChannel { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapShowChannelsAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapShowChannelsAction.cs index 79f196e..d94aa77 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapShowChannelsAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapShowChannelsAction.cs @@ -1,32 +1,28 @@ using System; +using AsterNET.Manager.Event; + namespace AsterNET.Manager.Action { - /// - /// The ZapShowChannelsAction requests the state of all zap channels.
- /// For each zap channel a ZapShowChannelsEvent is generated. After all zap - /// channels have been listed a ZapShowChannelsCompleteEvent is generated. - ///
- /// - /// - public class ZapShowChannelsAction : ManagerActionEvent - { - /// - /// Get the name of this action, i.e. "ZapShowChannels". - /// - public override string Action - { - get { return "ZapShowChannels"; } - } - public override Type ActionCompleteEventClass() - { - return typeof(Event.ZapShowChannelsCompleteEvent); - } - - /// - /// Creates a new ZapShowChannelsAction. - /// - public ZapShowChannelsAction() - { - } - } + /// + /// The ZapShowChannelsAction requests the state of all zap channels.
+ /// For each zap channel a ZapShowChannelsEvent is generated. After all zap + /// channels have been listed a ZapShowChannelsCompleteEvent is generated. + ///
+ /// + /// + public class ZapShowChannelsAction : ManagerActionEvent + { + /// + /// Get the name of this action, i.e. "ZapShowChannels". + /// + public override string Action + { + get { return "ZapShowChannels"; } + } + + public override Type ActionCompleteEventClass() + { + return typeof (ZapShowChannelsCompleteEvent); + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapTransferAction.cs b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapTransferAction.cs index eb3489e..8aa2fe3 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Action/ZapTransferAction.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Action/ZapTransferAction.cs @@ -1,28 +1,22 @@ -using System; namespace AsterNET.Manager.Action { - /// - /// The ZapTransferAction transfers a zap channel. - /// - public class ZapTransferAction : ManagerAction - { - private int zapChannel; + /// + /// The ZapTransferAction transfers a zap channel. + /// + public class ZapTransferAction : ManagerAction + { + /// + /// Get the name of this action, i.e. "ZapTransfer". + /// + public override string Action + { + get { return "ZapTransfer"; } + } - /// - /// Get the name of this action, i.e. "ZapTransfer". - /// - override public string Action - { - get { return "ZapTransfer"; } - } - /// - /// Get/Set the number of the zap channel to transfer.
- /// This property is mandatory. - ///
- public int ZapChannel - { - get { return this.zapChannel; } - set { this.zapChannel = value; } - } - } + /// + /// Get/Set the number of the zap channel to transfer.
+ /// This property is mandatory. + ///
+ public int ZapChannel { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/AsteriskVersion.cs b/Asterisk.2013/Asterisk.NET/Manager/AsteriskVersion.cs index 1235c4e..7877fdc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/AsteriskVersion.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/AsteriskVersion.cs @@ -1,17 +1,15 @@ -using System; - namespace AsterNET.Manager { - public enum AsteriskVersion - { - ASTERISK_1_0 = 10, - ASTERISK_1_2 = 12, - ASTERISK_1_4 = 14, - ASTERISK_1_6 = 16, + public enum AsteriskVersion + { + ASTERISK_1_0 = 10, + ASTERISK_1_2 = 12, + ASTERISK_1_4 = 14, + ASTERISK_1_6 = 16, ASTERISK_1_8 = 18, - ASTERISK_10 = 100, - ASTERISK_11 = 110, - ASTERISK_12 = 120, - ASTERISK_13 = 130 - } -} + ASTERISK_10 = 100, + ASTERISK_11 = 110, + ASTERISK_12 = 120, + ASTERISK_13 = 130 + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AGIExecEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AGIExecEvent.cs index 7f5bdec..d4910e7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AGIExecEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AGIExecEvent.cs @@ -1,51 +1,27 @@ -using System; - namespace AsterNET.Manager.Event { - /// - /// AgiExecEvents are triggered when an AGI command is executed.
- /// For each command two events are triggered: one before excution ("Start") and one after execution ("End"). - ///
- public class AGIExecEvent : ManagerEvent - { - private string subEvent; - private long commandId; - private string command; - private int resultCode; - private string result; + /// + /// AgiExecEvents are triggered when an AGI command is executed.
+ /// For each command two events are triggered: one before excution ("Start") and one after execution ("End"). + ///
+ public class AGIExecEvent : ManagerEvent + { + /// + /// Creates a new AGIExecEvent. + /// + public AGIExecEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Creates a new AGIExecEvent. - /// - public AGIExecEvent(ManagerConnection source) - : base(source) - { - } + public long CommandId { get; set; } - public long CommandId - { - get { return commandId; } - set { this.commandId = value; } - } - public string Command - { - get { return command; } - set { this.command = value; } - } - public string SubEvent - { - get { return subEvent; } - set { this.subEvent = value; } - } - public string Result - { - get { return result; } - set { this.result = value; } - } - public int ResultCode - { - get { return resultCode; } - set { this.resultCode = value; } - } - } -} + public string Command { get; set; } + + public string SubEvent { get; set; } + + public string Result { get; set; } + + public int ResultCode { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentEvent.cs index a54987a..ba70968 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractAgentEvent.cs @@ -1,42 +1,28 @@ namespace AsterNET.Manager.Event { - /// - /// Abstract base class for several agent related events. - /// - public abstract class AbstractAgentEvent : AbstractAgentVariables - { - private string queue; - private string member; - private string memberName; + /// + /// Abstract base class for several agent related events. + /// + public abstract class AbstractAgentEvent : AbstractAgentVariables + { + public AbstractAgentEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the name of the queue. - /// - public string Queue - { - get { return queue; } - set { this.queue = value; } - } - /// - /// Get/Set the name of the member's interface. - /// - public string Member - { - get { return member; } - set { this.member = value; } - } + /// + /// Get/Set the name of the queue. + /// + public string Queue { get; set; } - /// - /// Get/Set the name of the member's interface. - /// - public string MemberName - { - get { return memberName; } - set { this.memberName = value; } - } + /// + /// Get/Set the name of the member's interface. + /// + public string Member { get; set; } - public AbstractAgentEvent(ManagerConnection source) - : base(source) - { } - } + /// + /// Get/Set the name of the member's interface. + /// + public string MemberName { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractMeetmeEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractMeetmeEvent.cs index cf1d477..e9523e6 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractMeetmeEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractMeetmeEvent.cs @@ -1,30 +1,20 @@ namespace AsterNET.Manager.Event { - /// - /// Abstract base class providing common properties for meet me (asterisk's conference system) events. - /// - public abstract class AbstractMeetmeEvent : ManagerEvent - { - private string meetMe; - private int userNum; + /// + /// Abstract base class providing common properties for meet me (asterisk's conference system) events. + /// + public abstract class AbstractMeetmeEvent : ManagerEvent + { + public AbstractMeetmeEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the conference number. - /// - public string Meetme - { - get { return meetMe; } - set { this.meetMe = value; } - } - public int Usernum - { - get { return userNum; } - set { this.userNum = value; } - } - - public AbstractMeetmeEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the conference number. + /// + public string Meetme { get; set; } + + public int Usernum { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractParkedCallEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractParkedCallEvent.cs index 2266507..a6fe107 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractParkedCallEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractParkedCallEvent.cs @@ -1,50 +1,33 @@ namespace AsterNET.Manager.Event { - /// - /// Abstract base class for several call parking related events. - /// - public abstract class AbstractParkedCallEvent : ManagerEvent - { - private string exten; - private string callerId; - private string callerIdNum; - private string callerIdName; - - /// - /// Get/Set the extension the channel is or was parked at. - /// - public string Exten - { - get { return this.exten; } - set { this.exten = value; } - } - /// - /// Get/Set the Caller*ID number of the parked channel. - /// - public string CallerId - { - get { return this.callerId; } - set { this.callerId = value; } - } - /// - /// Get/Set the Caller*ID number of the parked channel. - /// - public string CallerIdNum - { - get { return this.callerIdNum; } - set { this.callerIdNum = value; } - } - /// - /// Get/Set the Caller*ID name of the parked channel. - /// - public string CallerIdName - { - get { return this.callerIdName; } - set { this.callerIdName = value; } - } + /// + /// Abstract base class for several call parking related events. + /// + public abstract class AbstractParkedCallEvent : ManagerEvent + { + public AbstractParkedCallEvent(ManagerConnection source) + : base(source) + { + } - public AbstractParkedCallEvent(ManagerConnection source) - : base(source) - { } - } + /// + /// Get/Set the extension the channel is or was parked at. + /// + public string Exten { get; set; } + + /// + /// Get/Set the Caller*ID number of the parked channel. + /// + public string CallerId { get; set; } + + /// + /// Get/Set the Caller*ID number of the parked channel. + /// + public string CallerIdNum { get; set; } + + /// + /// Get/Set the Caller*ID name of the parked channel. + /// + public string CallerIdName { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractQueueMemberEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractQueueMemberEvent.cs index f7aa48b..8ee619f 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractQueueMemberEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AbstractQueueMemberEvent.cs @@ -1,33 +1,24 @@ namespace AsterNET.Manager.Event { - /// - /// Abstract base class for several queue member related events. - /// - public abstract class AbstractQueueMemberEvent : ManagerEvent - { - private string queue; - private string location; + /// + /// Abstract base class for several queue member related events. + /// + public abstract class AbstractQueueMemberEvent : ManagerEvent + { + public AbstractQueueMemberEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Returns the name of the queue. - /// - public string Queue - { - get { return queue; } - set { this.queue = value; } - } - /// - /// Returns the name of the member's interface.
- /// E.g. the channel name or agent group. - ///
- public string Location - { - get { return location; } - set { this.location = value; } - } + /// + /// Returns the name of the queue. + /// + public string Queue { get; set; } - public AbstractQueueMemberEvent(ManagerConnection source) - : base(source) - { } - } + /// + /// Returns the name of the member's interface.
+ /// E.g. the channel name or agent group. + ///
+ public string Location { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLoginEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLoginEvent.cs index 64c2777..67d6879 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLoginEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLoginEvent.cs @@ -1,31 +1,22 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentCallbackLoginEvent is triggered when an agent is successfully logged in using AgentCallbackLogin.
- /// It is implemented in channels/chan_agent.c - ///
- /// - public class AgentCallbackLoginEvent : ManagerEvent - { - private string agent; - private string loginChan; + /// + /// An AgentCallbackLoginEvent is triggered when an agent is successfully logged in using AgentCallbackLogin.
+ /// It is implemented in channels/chan_agent.c + ///
+ /// + public class AgentCallbackLoginEvent : ManagerEvent + { + public AgentCallbackLoginEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the name of the agent that logged in. - /// - public string Agent - { - get { return agent; } - set { this.agent = value; } - } - public string LoginChan - { - get { return loginChan; } - set { this.loginChan = value; } - } + /// + /// Get/Set the name of the agent that logged in. + /// + public string Agent { get; set; } - public AgentCallbackLoginEvent(ManagerConnection source) - : base(source) - { } - } + public string LoginChan { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLogoffEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLogoffEvent.cs index 26466f5..a2eb014 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLogoffEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCallbackLogoffEvent.cs @@ -1,92 +1,48 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using - /// AgentCallbackLogin is logged of.
- /// It is implemented in channels/chan_agent.c - ///
- /// - public class AgentCallbackLogoffEvent : ManagerEvent - { - private string agent; - private string loginChan; - private string loginTime; - private string reason; + /// + /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using + /// AgentCallbackLogin is logged of.
+ /// It is implemented in channels/chan_agent.c + ///
+ /// + public class AgentCallbackLogoffEvent : ManagerEvent + { + #region Agent - #region Agent - /// Returns the name of the agent that logged off. - /// Sets the name of the agent that logged off. - public string Agent - { - get - { - return agent; - } - - set - { - this.agent = value; - } + /// Returns the name of the agent that logged off. + /// Sets the name of the agent that logged off. + public string Agent { get; set; } - } - #endregion + #endregion - #region LoginChan - public string LoginChan - { - get - { - return loginChan; - } - - set - { - this.loginChan = value; - } + #region LoginChan - } - #endregion + public string LoginChan { get; set; } - #region LoginTime - public string LoginTime - { - get - { - return loginTime; - } - - set - { - this.loginTime = value; - } + #endregion - } - #endregion + #region LoginTime - #region Reason - /// - /// Returns the reason for the logoff. The reason is set to Autologoff if the agent has been - /// logged off due to not answering the phone in time. Autologoff is configured by setting - /// autologoff to the appropriate number of seconds in agents.conf. - /// - /// Sets the reason for the logoff. - public string Reason - { - get - { - return reason; - } - - set - { - this.reason = value; - } + public string LoginTime { get; set; } - } - #endregion + #endregion - public AgentCallbackLogoffEvent(ManagerConnection source) - : base(source) - { } - } + #region Reason + + /// + /// Returns the reason for the logoff. The reason is set to Autologoff if the agent has been + /// logged off due to not answering the phone in time. Autologoff is configured by setting + /// autologoff to the appropriate number of seconds in agents.conf. + /// + /// Sets the reason for the logoff. + public string Reason { get; set; } + + #endregion + + public AgentCallbackLogoffEvent(ManagerConnection source) + : base(source) + { + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCalledEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCalledEvent.cs index b182e18..6cfe250 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCalledEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCalledEvent.cs @@ -1,89 +1,43 @@ -using System.Collections; namespace AsterNET.Manager.Event { - /// - /// An AgentCalledEvent is triggered when an agent is rung.
- /// To enable AgentCalledEvents you have to set eventwhencalled = yes in queues.conf.
- /// This event is implemented in apps/app_queue.c - ///
- public class AgentCalledEvent : AbstractAgentVariables - { - private string agentCalled; - private string agentName; - private string callerId; - private string callerIdName; - private string callerIdNum; - private string channelCalling; - private string context; - private string destinationChannel; - private string extension; - private string priority; - private string queue; + /// + /// An AgentCalledEvent is triggered when an agent is rung.
+ /// To enable AgentCalledEvents you have to set eventwhencalled = yes in queues.conf.
+ /// This event is implemented in apps/app_queue.c + ///
+ public class AgentCalledEvent : AbstractAgentVariables + { + public AgentCalledEvent(ManagerConnection source) + : base(source) + { + } - public string Queue - { - get { return this.queue; } - set { this.queue = value; } - } - public string AgentName - { - get { return agentName; } - set { this.agentName = value; } - } - public string AgentCalled - { - get { return agentCalled; } - set { this.agentCalled = value; } - } - public string ChannelCalling - { - get { return channelCalling; } - set { this.channelCalling = value; } - } - public string DestinationChannel - { - get { return this.destinationChannel; } - set { this.destinationChannel = value; } - } - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - /// - /// Get/Set the Caller*ID number of the calling channel. - /// - public string CallerIdNum - { - get { return callerIdNum; } - set { this.callerIdNum = value; } - } - /// - /// Get/Set the Caller*ID name of the calling channel. - /// - public string CallerIdName - { - get { return callerIdName; } - set { this.callerIdName = value; } - } - public string Context - { - get { return context; } - set { this.context = value; } - } - public string Extension - { - get { return extension; } - set { this.extension = value; } - } - public string Priority - { - get { return priority; } - set { this.priority = value; } - } - - public AgentCalledEvent(ManagerConnection source) - : base(source) - { } - } + public string Queue { get; set; } + + public string AgentName { get; set; } + + public string AgentCalled { get; set; } + + public string ChannelCalling { get; set; } + + public string DestinationChannel { get; set; } + + public string CallerId { get; set; } + + /// + /// Get/Set the Caller*ID number of the calling channel. + /// + public string CallerIdNum { get; set; } + + /// + /// Get/Set the Caller*ID name of the calling channel. + /// + public string CallerIdName { get; set; } + + public string Context { get; set; } + + public string Extension { get; set; } + + public string Priority { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCompleteEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCompleteEvent.cs index ddd227f..82181d2 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCompleteEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentCompleteEvent.cs @@ -1,41 +1,28 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentCompleteEvent is triggered when at the end of a call if the caller was connected to an agent. - /// - public class AgentCompleteEvent : AbstractAgentEvent - { - private long holdTime; - private string reason; - private long talkTime; + /// + /// An AgentCompleteEvent is triggered when at the end of a call if the caller was connected to an agent. + /// + public class AgentCompleteEvent : AbstractAgentEvent + { + public AgentCompleteEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the amount of time the caller was on hold. - /// - public long HoldTime - { - get { return holdTime; } - set { this.holdTime = value; } - } - /// - /// Get/Set the amount of time the caller talked to the agent. - /// - public long TalkTime - { - get { return talkTime; } - set { this.talkTime = value; } - } - /// - /// Get/Set if the agent or the caller terminated the call. - /// - public string Reason - { - get { return reason; } - set { this.reason = value; } - } - - public AgentCompleteEvent(ManagerConnection source) - : base(source) - { } - } + /// + /// Get/Set the amount of time the caller was on hold. + /// + public long HoldTime { get; set; } + + /// + /// Get/Set the amount of time the caller talked to the agent. + /// + public long TalkTime { get; set; } + + /// + /// Get/Set if the agent or the caller terminated the call. + /// + public string Reason { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentConnectEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentConnectEvent.cs index 9c59847..d49e70f 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentConnectEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentConnectEvent.cs @@ -1,44 +1,28 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentConnectEvent is triggered when a caller is connected to an agent. - /// - public class AgentConnectEvent : AbstractAgentEvent - { - private string bridgedChannel; - private long holdTime; - private long ringTime; + /// + /// An AgentConnectEvent is triggered when a caller is connected to an agent. + /// + public class AgentConnectEvent : AbstractAgentEvent + { + public AgentConnectEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the amount of time the caller was on hold. - /// - public long HoldTime - { - get { return holdTime; } - set { this.holdTime = value; } - } + /// + /// Get/Set the amount of time the caller was on hold. + /// + public long HoldTime { get; set; } - /// - /// Get/Set bridged channel. - /// - public string BridgedChannel - { - get { return this.bridgedChannel; } - set { this.bridgedChannel = value; } - } + /// + /// Get/Set bridged channel. + /// + public string BridgedChannel { get; set; } - /// - /// Get/Set the amount of time the caller was on ring. - /// - public long RingTime - { - get { return ringTime; } - set { this.ringTime = value; } - } - - public AgentConnectEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the amount of time the caller was on ring. + /// + public long RingTime { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLoginEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLoginEvent.cs index 4380dfc..0ccd917 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLoginEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLoginEvent.cs @@ -1,32 +1,22 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentLoginEvent is triggered when an agent is successfully logged in using AgentLogin.
- /// It is implemented in channels/chan_agent.c - ///
- /// - public class AgentLoginEvent : ManagerEvent - { - private string agent; - private string loginChan; + /// + /// An AgentLoginEvent is triggered when an agent is successfully logged in using AgentLogin.
+ /// It is implemented in channels/chan_agent.c + ///
+ /// + public class AgentLoginEvent : ManagerEvent + { + public AgentLoginEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the name of the agent that logged in. - /// - public string Agent - { - get { return agent; } - set { this.agent = value; } - } - public string LoginChan - { - get { return loginChan; } - set { this.loginChan = value; } - } + /// + /// Get/Set the name of the agent that logged in. + /// + public string Agent { get; set; } - public AgentLoginEvent(ManagerConnection source) - : base(source) - { - } - } + public string LoginChan { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLogoffEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLogoffEvent.cs index 3892314..923153e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLogoffEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentLogoffEvent.cs @@ -1,32 +1,23 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using AgentLogin is logged of.
- /// It is implemented in channels/chan_agent.c - ///
- /// - public class AgentLogoffEvent : ManagerEvent - { - private string agent; - private string loginTime; - - /// - /// Get/Set the name of the agent that logged off. - /// - public string Agent - { - get { return agent; } - set { this.agent = value; } - } - public string LoginTime - { - get { return loginTime; } - set { this.loginTime = value; } - } - - public AgentLogoffEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// An AgentCallbackLogoffEvent is triggered when an agent that previously logged in using AgentLogin is logged of. + ///
+ /// It is implemented in channels/chan_agent.c + ///
+ /// + public class AgentLogoffEvent : ManagerEvent + { + public AgentLogoffEvent(ManagerConnection source) + : base(source) + { + } + + /// + /// Get/Set the name of the agent that logged off. + /// + public string Agent { get; set; } + + public string LoginTime { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentsEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentsEvent.cs index e9a0490..023d5da 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AgentsEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AgentsEvent.cs @@ -1,82 +1,56 @@ namespace AsterNET.Manager.Event { - /// - /// An AgentsEvent is triggered for each agent in response to an AgentsAction.
- /// Available since Asterisk 1.2 - ///
- /// - public class AgentsEvent : ResponseEvent - { - private string agent; - private string name; - private string status; - private string loggedInChan; - private string talkingTo; - private long loggedInTime; + /// + /// An AgentsEvent is triggered for each agent in response to an AgentsAction.
+ /// Available since Asterisk 1.2 + ///
+ /// + public class AgentsEvent : ResponseEvent + { + public AgentsEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the agentid. - /// - public string Agent - { - get { return this.agent; } - set { this.agent = value; } - } - /// - /// Get/Set the name of this agent. - /// - public string Name - { - get { return this.name; } - set { this.name = value; } - } - /// - /// Get/Set the status of this agent.
- /// This is one of - ///
- ///
"AGENT_LOGGEDOFF"
- ///
Agent isn't logged in
- ///
"AGENT_IDLE"
- ///
Agent is logged in, and waiting for call
- ///
"AGENT_ONCALL"
- ///
Agent is logged in, and on a call
- ///
"AGENT_UNKNOWN"
- ///
Don't know anything about agent. Shouldn't ever get this.
- ///
- ///
- public string Status - { - get { return this.status; } - set { this.status = value; } - } - /// - /// Get/Set the name of channel this agent logged in from or "n/a" if the agent is not logged in. - /// - public string LoggedInChan - { - get { return this.loggedInChan; } - set { this.loggedInChan = value; } - } - /// - /// Get/Set the time (in seconds since 01/01/1970) when the agent logged in or 0 if the user is not logged. - /// - public long LoggedInTime - { - get { return this.loggedInTime; } - set { this.loggedInTime = value; } - } - /// - /// Get/Set the numerical Caller*ID of the channel this agent is talking toor "n/a" if this agent is talking to nobody. - /// - public string TalkingTo - { - get { return this.talkingTo; } - set { this.talkingTo = value; } - } + /// + /// Get/Set the agentid. + /// + public string Agent { get; set; } - public AgentsEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the name of this agent. + /// + public string Name { get; set; } + + /// + /// Get/Set the status of this agent.
+ /// This is one of + ///
+ ///
"AGENT_LOGGEDOFF"
+ ///
Agent isn't logged in
+ ///
"AGENT_IDLE"
+ ///
Agent is logged in, and waiting for call
+ ///
"AGENT_ONCALL"
+ ///
Agent is logged in, and on a call
+ ///
"AGENT_UNKNOWN"
+ ///
Don't know anything about agent. Shouldn't ever get this.
+ ///
+ ///
+ public string Status { get; set; } + + /// + /// Get/Set the name of channel this agent logged in from or "n/a" if the agent is not logged in. + /// + public string LoggedInChan { get; set; } + + /// + /// Get/Set the time (in seconds since 01/01/1970) when the agent logged in or 0 if the user is not logged. + /// + public long LoggedInTime { get; set; } + + /// + /// Get/Set the numerical Caller*ID of the channel this agent is talking toor "n/a" if this agent is talking to nobody. + /// + public string TalkingTo { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AlarmEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AlarmEvent.cs index 6765f3e..f6c8b23 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AlarmEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AlarmEvent.cs @@ -1,34 +1,28 @@ namespace AsterNET.Manager.Event { - /// - /// An AlarmEvent is triggered when a Zap channel enters or changes alarm state.
- /// It is implemented in channels/chan_zap.c - ///
- public class AlarmEvent : ManagerEvent - { - private string alarm; + /// + /// An AlarmEvent is triggered when a Zap channel enters or changes alarm state.
+ /// It is implemented in channels/chan_zap.c + ///
+ public class AlarmEvent : ManagerEvent + { + public AlarmEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the kind of alarm that happened.
- /// This may be one of - ///
    - ///
  • Red Alarm
  • - ///
  • Yellow Alarm
  • - ///
  • Blue Alarm
  • - ///
  • Recovering
  • - ///
  • Loopback
  • - ///
  • Not Open
  • - ///
- ///
- public string Alarm - { - get { return alarm; } - set { this.alarm = value; } - } - - public AlarmEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the kind of alarm that happened.
+ /// This may be one of + ///
    + ///
  • Red Alarm
  • + ///
  • Yellow Alarm
  • + ///
  • Blue Alarm
  • + ///
  • Recovering
  • + ///
  • Loopback
  • + ///
  • Not Open
  • + ///
+ ///
+ public string Alarm { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/AsyncAGIEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/AsyncAGIEvent.cs index 87bef69..cc0388f 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/AsyncAGIEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/AsyncAGIEvent.cs @@ -1,40 +1,22 @@ -using System; - namespace AsterNET.Manager.Event { - public class AsyncAGIEvent : ManagerEvent - { - private string subEvent; - private string env; - private string result; - private string commandId; + public class AsyncAGIEvent : ManagerEvent + { + public string Result { get; set; } - public string Result - { - get { return result; } - set { result = value; } - } - public string CommandId - { - get { return commandId; } - set { commandId = value; } - } - public string SubEvent - { - get { return subEvent; } - set { subEvent = value; } - } - public string Env - { - get { return env; } - set { env = value; } - } + public string CommandId { get; set; } - #region Constructor - AsyncAGIEvent(ManagerConnection source) - public AsyncAGIEvent(ManagerConnection source) - : base(source) - { - } - #endregion - } -} + public string SubEvent { get; set; } + + public string Env { get; set; } + + #region Constructor - AsyncAGIEvent(ManagerConnection source) + + public AsyncAGIEvent(ManagerConnection source) + : base(source) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/CdrEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/CdrEvent.cs index 406c92e..18c3c8e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/CdrEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/CdrEvent.cs @@ -1,114 +1,48 @@ namespace AsterNET.Manager.Event { - /// - /// A CdrEvent is triggered when a call detail record is generated, usually at the end of a call.
- /// To enable CdrEvents you have to add enabled = yes to the general section in - /// cdr_manager.conf.
- /// This event is implemented in cdr/cdr_manager.c - ///
- public class CdrEvent : ManagerEvent - { - private string accountCode; - private string src; - private string destination; - private string destinationContext; - private string callerId; - private string destinationChannel; - private string lastApplication; - private string lastData; - private string startTime; - private string answerTime; - private string endTime; - private long duration; - private long billableSeconds; - private string disposition; - private string amaFlags; - private string userField; + /// + /// A CdrEvent is triggered when a call detail record is generated, usually at the end of a call.
+ /// To enable CdrEvents you have to add enabled = yes to the general section in + /// cdr_manager.conf.
+ /// This event is implemented in cdr/cdr_manager.c + ///
+ public class CdrEvent : ManagerEvent + { + public CdrEvent(ManagerConnection source) + : base(source) + { + } - public CdrEvent(ManagerConnection source) - : base(source) - { - } + public string AccountCode { get; set; } - public string AccountCode - { - get { return accountCode; } - set { this.accountCode = value; } - } - public string Src - { - get { return src; } - set { this.src = value; } - } - public string Destination - { - get { return destination; } - set { this.destination = value; } - } - public string DestinationContext - { - get { return destinationContext; } - set { this.destinationContext = value; } - } - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - public string DestinationChannel - { - get { return destinationChannel; } - set { this.destinationChannel = value; } - } - public string LastApplication - { - get { return lastApplication; } - set { this.lastApplication = value; } - } - public string LastData - { - get { return lastData; } - set { this.lastData = value; } - } - public string StartTime - { - get { return startTime; } - set { this.startTime = value; } - } - public string AnswerTime - { - get { return answerTime; } - set { this.answerTime = value; } - } - public string EndTime - { - get { return endTime; } - set { this.endTime = value; } - } - public long Duration - { - get { return duration; } - set { this.duration = value; } - } - public long BillableSeconds - { - get { return billableSeconds; } - set { this.billableSeconds = value; } - } - public string Disposition - { - get { return disposition; } - set { this.disposition = value; } - } - public string AmaFlags - { - get { return amaFlags; } - set { this.amaFlags = value; } - } - public string UserField - { - get { return userField; } - set { this.userField = value; } - } - } + public string Src { get; set; } + + public string Destination { get; set; } + + public string DestinationContext { get; set; } + + public string CallerId { get; set; } + + public string DestinationChannel { get; set; } + + public string LastApplication { get; set; } + + public string LastData { get; set; } + + public string StartTime { get; set; } + + public string AnswerTime { get; set; } + + public string EndTime { get; set; } + + public long Duration { get; set; } + + public long BillableSeconds { get; set; } + + public string Disposition { get; set; } + + public string AmaFlags { get; set; } + + public string UserField { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelReloadEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelReloadEvent.cs index 4cbb670..e57cc02 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelReloadEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelReloadEvent.cs @@ -1,57 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace AsterNET.Manager.Event { - public class ChannelReloadEvent : ManagerEvent - { - private string channelType; - private string reloadreason; - private int registryCount; - private int userCount; - private int peerCount; + public class ChannelReloadEvent : ManagerEvent + { + public ChannelReloadEvent(ManagerConnection source) + : base(source) + { + } - /// - /// For SIP peers this is "SIP". - /// - public string ChannelType - { - get { return channelType; } - set { this.channelType = value; } - } + /// + /// For SIP peers this is "SIP". + /// + public string ChannelType { get; set; } - /// - /// Get/Set the name of the channel. - /// - public string ReloadReason - { - get { return reloadreason; } - set { this.reloadreason = value; } - } + /// + /// Get/Set the name of the channel. + /// + public string ReloadReason { get; set; } - public int UserCount - { - get { return userCount; } - set { this.userCount = value; } - } + public int UserCount { get; set; } - public int PeerCount - { - get { return peerCount; } - set { this.peerCount = value; } - } + public int PeerCount { get; set; } - public int RegistryCount - { - get { return registryCount; } - set { this.registryCount = value; } - } - - public ChannelReloadEvent(ManagerConnection source) - : base(source) - { - } - - } -} + public int RegistryCount { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelUpdateEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelUpdateEvent.cs index d676318..3bf12fe 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelUpdateEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ChannelUpdateEvent.cs @@ -1,75 +1,35 @@ -using System; - namespace AsterNET.Manager.Event { - public class ChannelUpdateEvent : ManagerEvent - { - private string channelType; - private string sipCallId; - private string sipFullContact; - private string peerName; - private string iax2callnoLocal; - private string iax2callnoRemote; - private string iax2peer; - private string gtalkSID; + public class ChannelUpdateEvent : ManagerEvent + { + /// + /// Creates a new ChannelUpdateEvent. + /// + public ChannelUpdateEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set channel type - /// "SIP", - /// "IAX2", - /// "GTALK" - /// - public string ChannelType - { - get { return this.channelType; } - set { this.channelType = value; } - } + /// + /// Get/Set channel type + /// "SIP", + /// "IAX2", + /// "GTALK" + /// + public string ChannelType { get; set; } - public string SipCallId - { - get { return this.sipCallId; } - set { this.sipCallId = value; } - } + public string SipCallId { get; set; } - public string SipFullContact - { - get { return this.sipFullContact; } - set { this.sipFullContact = value; } - } + public string SipFullContact { get; set; } - public string PeerName - { - get { return this.peerName; } - set { this.peerName = value; } - } + public string PeerName { get; set; } - public string IAX2CallnoLocal - { - get { return this.iax2callnoLocal; } - set { this.iax2callnoLocal = value; } - } - public string IAX2CallnoRemote - { - get { return this.iax2callnoRemote; } - set { this.iax2callnoRemote = value; } - } - public string IAX2Peer - { - get { return this.iax2peer; } - set { this.iax2peer = value; } - } - public string GTalkSID - { - get { return this.gtalkSID; } - set { this.gtalkSID = value; } - } + public string IAX2CallnoLocal { get; set; } - /// - /// Creates a new ChannelUpdateEvent. - /// - public ChannelUpdateEvent(ManagerConnection source) - : base(source) - { - } -} -} + public string IAX2CallnoRemote { get; set; } + + public string IAX2Peer { get; set; } + + public string GTalkSID { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ConnectEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ConnectEvent.cs index 5cb5d34..f44020c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/ConnectEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ConnectEvent.cs @@ -1,25 +1,19 @@ namespace AsterNET.Manager.Event { - /// - /// A ConnectEvent is triggered after successful login to the asterisk server.
- /// It is a pseudo event not directly related to an asterisk generated event. - ///
- public class ConnectEvent : ConnectionStateEvent - { - /// The version of the manager/proxy protocol. - private string protocolIdentifier; - public ConnectEvent(ManagerConnection source) - : base(source) - { - } + /// + /// A ConnectEvent is triggered after successful login to the asterisk server.
+ /// It is a pseudo event not directly related to an asterisk generated event. + ///
+ public class ConnectEvent : ConnectionStateEvent + { + public ConnectEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the version of the protocol. - /// - public string ProtocolIdentifier - { - get { return protocolIdentifier; } - set { this.protocolIdentifier = value; } - } - } + /// + /// Get/Set the version of the protocol. + /// + public string ProtocolIdentifier { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/DBGetResponseEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/DBGetResponseEvent.cs index b103d6e..3e466ef 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/DBGetResponseEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/DBGetResponseEvent.cs @@ -1,44 +1,30 @@ namespace AsterNET.Manager.Event { - /// - /// A DBGetResponseEvent is sent in response to a DBGetAction and contains the entry that was queried.
- /// Available since Asterisk 1.2 - ///
- /// - public class DBGetResponseEvent : ResponseEvent - { - private string family; - private string key; - private string val; + /// + /// A DBGetResponseEvent is sent in response to a DBGetAction and contains the entry that was queried.
+ /// Available since Asterisk 1.2 + ///
+ /// + public class DBGetResponseEvent : ResponseEvent + { + public DBGetResponseEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the family of the database entry that was queried. - /// - public string Family - { - get { return this.family; } - set { this.family = value; } - } - /// - /// Get/Set the key of the database entry that was queried. - /// - public string Key - { - get { return this.key; } - set { this.key = value; } - } - /// - /// Get/Set the value of the database entry that was queried. - /// - public string Val - { - get { return val; } - set { this.val = value; } - } + /// + /// Get/Set the family of the database entry that was queried. + /// + public string Family { get; set; } - public DBGetResponseEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the key of the database entry that was queried. + /// + public string Key { get; set; } + + /// + /// Get/Set the value of the database entry that was queried. + /// + public string Val { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/DNDStateEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/DNDStateEvent.cs index b3ac126..a038567 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/DNDStateEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/DNDStateEvent.cs @@ -1,40 +1,29 @@ namespace AsterNET.Manager.Event { - /// - /// A DNDStateEvent is triggered by the Zap channel driver when a channel enters - /// or leaves DND (do not disturb) state.
- /// It is implemented in channels/chan_zap.c.
- /// Available since Asterisk 1.2 - ///
- public class DNDStateEvent : ManagerEvent - { - private string state; - private string status; + /// + /// A DNDStateEvent is triggered by the Zap channel driver when a channel enters + /// or leaves DND (do not disturb) state.
+ /// It is implemented in channels/chan_zap.c.
+ /// Available since Asterisk 1.2 + ///
+ public class DNDStateEvent : ManagerEvent + { + /// + /// Creates a new DNDStateEvent. + /// + public DNDStateEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set DND state of the channel. "enabled" if do not disturb is on, "disabled" if it is off. - /// - public string State - { - get { return this.state; } - set { this.state = value; } - } + /// + /// Get/Set DND state of the channel. "enabled" if do not disturb is on, "disabled" if it is off. + /// + public string State { get; set; } - /// - /// Get/Set DND state of the channel. "enabled" if do not disturb is on, "disabled" if it is off. - /// - public string Status - { - get { return this.status; } - set { this.status = value; } - } - - /// - /// Creates a new DNDStateEvent. - /// - public DNDStateEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set DND state of the channel. "enabled" if do not disturb is on, "disabled" if it is off. + /// + public string Status { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/DTMFEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/DTMFEvent.cs index 9765105..758e4a1 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/DTMFEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/DTMFEvent.cs @@ -1,43 +1,21 @@ -using System; -using System.Collections.Generic; -using System.Text; - namespace AsterNET.Manager.Event { - public class DTMFEvent : ManagerEvent - { - private string digit; - private string direction; - private bool begin; - private bool end; + public class DTMFEvent : ManagerEvent + { + /// + /// Creates a new DialEvent. + /// + public DTMFEvent(ManagerConnection source) + : base(source) + { + } - public string Direction - { - get { return direction; } - set { this.direction = value; } - } - public string Digit - { - get { return digit; } - set { this.digit = value; } - } - public bool Begin - { - get { return begin; } - set { this.begin = value; } - } - public bool End - { - get { return end; } - set { this.end = value; } - } + public string Direction { get; set; } - /// - /// Creates a new DialEvent. - /// - public DTMFEvent(ManagerConnection source) - : base(source) - { - } - } -} + public string Digit { get; set; } + + public bool Begin { get; set; } + + public bool End { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/FaxReceivedEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/FaxReceivedEvent.cs index 12ece36..73665b2 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/FaxReceivedEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/FaxReceivedEvent.cs @@ -1,98 +1,56 @@ -using AsterNET.Manager.Event; namespace AsterNET.Manager.Event { - /// - /// A FaxReceivedEvent is triggered by spandsp after a new fax has been received.
- /// It is only available if you installed the spandsp patches to Asterisk.
- /// See http://soft-switch.org/installing-spandsp.html for details.
- /// Implemented in apps/app_rxfax.c. - ///
- public class FaxReceivedEvent : AbstractAgentEvent - { - private string exten; - private string callerId; - private string remoteStationId; - private string localStationId; - private int pagesTransferred; - private int resolution; - private int transferRate; - private string filename; + /// + /// A FaxReceivedEvent is triggered by spandsp after a new fax has been received.
+ /// It is only available if you installed the spandsp patches to Asterisk.
+ /// See http://soft-switch.org/installing-spandsp.html for details.
+ /// Implemented in apps/app_rxfax.c. + ///
+ public class FaxReceivedEvent : AbstractAgentEvent + { + public FaxReceivedEvent(ManagerConnection source) + : base(source) + { + } - public FaxReceivedEvent(ManagerConnection source) - : base(source) - { - } + /// + /// Get/Set the extension in Asterisk's dialplan the fax was received + /// + public string Exten { get; set; } - /// - /// Get/Set the extension in Asterisk's dialplan the fax was received - /// - public string Exten - { - get { return exten; } - set { exten = value; } - } + /// + /// Get/Set the Caller*ID of the calling party or an empty string if none is + /// + public string CallerId { get; set; } - /// - /// Get/Set the Caller*ID of the calling party or an empty string if none is - /// - public string CallerId - { - get { return callerId; } - set { callerId = value; } - } + /// + /// Get/Set the identifier of the remote fax station. + /// + public string RemoteStationId { get; set; } - /// - /// Get/Set the identifier of the remote fax station. - /// - public string RemoteStationId - { - get { return remoteStationId; } - set { remoteStationId = value; } - } + /// + /// Get/Set the identifier of the local fax station. + /// + public string LocalStationId { get; set; } - /// - /// Get/Set the identifier of the local fax station. - /// - public string LocalStationId - { - get { return localStationId; } - set { localStationId = value; } - } + /// + /// Get/Set the number of pages transferred. + /// + public int PagesTransferred { get; set; } - /// - /// Get/Set the number of pages transferred. - /// - public int PagesTransferred - { - get { return pagesTransferred; } - set { pagesTransferred = value; } - } + /// + /// Get/Set the row resolution of the received fax. + /// + public int Resolution { get; set; } - /// - /// Get/Set the row resolution of the received fax. - /// - public int Resolution - { - get { return resolution; } - set { resolution = value; } - } + /// + /// Get/Set the transfer rate in bits/s. + /// + public int TransferRate { get; set; } - /// - /// Get/Set the transfer rate in bits/s. - /// - public int TransferRate - { - get { return transferRate; } - set { transferRate = value; } - } - - /// - /// Get/Set the filename of the received fax including its full path on the Asterisk server. - /// - public string Filename - { - get { return filename; } - set { filename = value; } - } - } -} + /// + /// Get/Set the filename of the received fax including its full path on the Asterisk server. + /// + public string Filename { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/HoldEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/HoldEvent.cs index a6cd5ad..f02d4aa 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/HoldEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/HoldEvent.cs @@ -1,24 +1,18 @@ namespace AsterNET.Manager.Event { - /// - /// A HoldEvent is triggered by the SIP channel driver when a channel is put on hold.
- /// It is implemented in channels/chan_sip.c.
- /// Available since Asterisk 1.2 - ///
- /// - public class HoldEvent : ManagerEvent - { - private string status; + /// + /// A HoldEvent is triggered by the SIP channel driver when a channel is put on hold.
+ /// It is implemented in channels/chan_sip.c.
+ /// Available since Asterisk 1.2 + ///
+ /// + public class HoldEvent : ManagerEvent + { + public HoldEvent(ManagerConnection source) + : base(source) + { + } - public string Status - { - get { return this.status; } - set { this.status = value; } - } - - public HoldEvent(ManagerConnection source) - : base(source) - { - } - } + public string Status { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/HoldedCallEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/HoldedCallEvent.cs index 13f15bf..90e4018 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/HoldedCallEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/HoldedCallEvent.cs @@ -1,52 +1,34 @@ namespace AsterNET.Manager.Event { - /// - /// A HoldedCallEvent is triggered when a channel is put on hold.
- /// It is implemented in res/res_features.c - ///
- public class HoldedCallEvent : ManagerEvent - { - private string uniqueId1; - private string uniqueId2; - private string channel1; - private string channel2; + /// + /// A HoldedCallEvent is triggered when a channel is put on hold.
+ /// It is implemented in res/res_features.c + ///
+ public class HoldedCallEvent : ManagerEvent + { + public HoldedCallEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the unique id of the channel that put the other channel on hold. - /// - public string UniqueId1 - { - get { return uniqueId1; } - set { this.uniqueId1 = value; } - } - /// - /// Get/Set the unique id of the channel that has been put on hold. - /// - public string UniqueId2 - { - get { return uniqueId2; } - set { this.uniqueId2 = value; } - } - /// - /// Get/Set the name of the channel that put the other channel on hold. - /// - public string Channel1 - { - get { return channel1; } - set { this.channel1 = value; } - } - /// - /// Get/Set the name of the channel that has been put on hold. - /// - public string Channel2 - { - get { return channel2; } - set { this.channel2 = value; } - } - - public HoldedCallEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the unique id of the channel that put the other channel on hold. + /// + public string UniqueId1 { get; set; } + + /// + /// Get/Set the unique id of the channel that has been put on hold. + /// + public string UniqueId2 { get; set; } + + /// + /// Get/Set the name of the channel that put the other channel on hold. + /// + public string Channel1 { get; set; } + + /// + /// Get/Set the name of the channel that has been put on hold. + /// + public string Channel2 { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/JabberEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/JabberEvent.cs index fd4c488..b05e47c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/JabberEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/JabberEvent.cs @@ -1,28 +1,18 @@ -using System; - namespace AsterNET.Manager.Event { - public class JabberEvent : ManagerEvent - { - private string account; - private string packet; + public class JabberEvent : ManagerEvent + { + public string Account { get; set; } - public string Account - { - get { return account; } - set { account = value; } - } - public string Packet - { - get { return packet; } - set { packet = value; } - } + public string Packet { get; set; } - #region Constructor - JabberEvent(ManagerConnection source) - public JabberEvent(ManagerConnection source) - : base(source) - { - } - #endregion - } -} + #region Constructor - JabberEvent(ManagerConnection source) + + public JabberEvent(ManagerConnection source) + : base(source) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/JitterBufStatsEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/JitterBufStatsEvent.cs index 98427c4..b6a27cb 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/JitterBufStatsEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/JitterBufStatsEvent.cs @@ -1,110 +1,42 @@ -using System; - namespace AsterNET.Manager.Event { - public class JitterBufStatsEvent : ManagerEvent - { - private string owner; - private int ping; - private int localJitter; - private int localJBDelay; - private int localTotalLost; - private int localLossPercent; - private int localDropped; - private int localooo; - private int localReceived; - private int remoteJitter; - private int remoteJBDelay; - private int remoteTotalLost; - private int remoteLossPercent; - private int remoteDropped; - private int remoteooo; - private int remoteReceived; + public class JitterBufStatsEvent : ManagerEvent + { + public JitterBufStatsEvent(ManagerConnection source) + : base(source) + { + } - public string Owner - { - get { return this.owner; } - set { this.owner = value; } - } - public int Ping - { - get { return this.ping; } - set { this.ping = value; } - } - public int LocalJitter - { - get { return this.localJitter; } - set { this.localJitter = value; } - } - public int LocalJBDelay - { - get { return this.localJBDelay; } - set { this.localJBDelay = value; } - } - public int LocalTotalLost - { - get { return this.localTotalLost; } - set { this.localTotalLost = value; } - } - public int LocalLossPercent - { - get { return this.localLossPercent; } - set { this.localLossPercent = value; } - } - public int LocalDropped - { - get { return this.localDropped; } - set { this.localDropped = value; } - } - public int Localooo - { - get { return this.localooo; } - set { this.localooo = value; } - } - public int LocalReceived - { - get { return this.localReceived; } - set { this.localReceived = value; } - } - public int RemoteJitter - { - get { return this.remoteJitter; } - set { this.remoteJitter = value; } - } - public int RemoteJBDelay - { - get { return this.remoteJBDelay; } - set { this.remoteJBDelay = value; } - } - public int RemoteTotalLost - { - get { return this.remoteTotalLost; } - set { this.remoteTotalLost = value; } - } - public int RemoteLossPercent - { - get { return this.remoteLossPercent; } - set { this.remoteLossPercent = value; } - } - public int RemoteDropped - { - get { return this.remoteDropped; } - set { this.remoteDropped = value; } - } - public int Remoteooo - { - get { return this.remoteooo; } - set { this.remoteooo = value; } - } - public int RemoteReceived - { - get { return this.remoteReceived; } - set { this.remoteReceived = value; } - } + public string Owner { get; set; } - public JitterBufStatsEvent(ManagerConnection source) - : base(source) - { - } - } -} + public int Ping { get; set; } + + public int LocalJitter { get; set; } + + public int LocalJBDelay { get; set; } + + public int LocalTotalLost { get; set; } + + public int LocalLossPercent { get; set; } + + public int LocalDropped { get; set; } + + public int Localooo { get; set; } + + public int LocalReceived { get; set; } + + public int RemoteJitter { get; set; } + + public int RemoteJBDelay { get; set; } + + public int RemoteTotalLost { get; set; } + + public int RemoteLossPercent { get; set; } + + public int RemoteDropped { get; set; } + + public int Remoteooo { get; set; } + + public int RemoteReceived { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/JoinEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/JoinEvent.cs index 18e70da..56a30d7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/JoinEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/JoinEvent.cs @@ -1,45 +1,31 @@ namespace AsterNET.Manager.Event { - /// - /// A JoinEvent is triggered when a channel joines a queue.
- /// It is implemented in apps/app_queue.c - ///
- public class JoinEvent : QueueEvent - { - private string callerId; - private string callerIdName; - private int position; + /// + /// A JoinEvent is triggered when a channel joines a queue.
+ /// It is implemented in apps/app_queue.c + ///
+ public class JoinEvent : QueueEvent + { + public JoinEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the Caller*ID number of the channel that joined the queue if set. - /// If the channel has no caller id set "unknown" is returned. - /// - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - /// - /// Get/Set the Caller*ID name of the channel that joined the queue if set. - /// If the channel has no caller id set "unknown" is returned. - /// - public string CallerIdName - { - get { return callerIdName; } - set { this.callerIdName = value; } - } - /// - /// Get/Set the position of the joined channel in the queue. - /// - public int Position - { - get { return position; } - set { this.position = value; } - } - - public JoinEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the Caller*ID number of the channel that joined the queue if set. + /// If the channel has no caller id set "unknown" is returned. + /// + public string CallerId { get; set; } + + /// + /// Get/Set the Caller*ID name of the channel that joined the queue if set. + /// If the channel has no caller id set "unknown" is returned. + /// + public string CallerIdName { get; set; } + + /// + /// Get/Set the position of the joined channel in the queue. + /// + public int Position { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/LogChannelEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/LogChannelEvent.cs index 5a0c7eb..a93db8a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/LogChannelEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/LogChannelEvent.cs @@ -1,59 +1,54 @@ -using System; namespace AsterNET.Manager.Event { - /// - /// A LogChannelEvent is triggered when logging is turned on or off.
- /// It is implemented in logger.c
- ///
- public class LogChannelEvent : ManagerEvent - { - private bool enabled; - private string reason; - private int reasonCode; + /// + /// A LogChannelEvent is triggered when logging is turned on or off.
+ /// It is implemented in logger.c
+ ///
+ public class LogChannelEvent : ManagerEvent + { + private string reason; + private int reasonCode; - /// - /// Get/Set if logging has been enabled or disabled. - /// - public bool Enabled - { - get { return enabled; } - set { this.enabled = value; } - } - /// - /// Get the textual representation of the reason for disabling logging. - /// - public string Reason - { - get { return this.reason; } - set - { - reason = ""; - reasonCode = 0; + public LogChannelEvent(ManagerConnection source) + : base(source) + { + } - if (string.IsNullOrEmpty(value)) - return; + /// + /// Get/Set if logging has been enabled or disabled. + /// + public bool Enabled { get; set; } - int spaceIdx; + /// + /// Get the textual representation of the reason for disabling logging. + /// + public string Reason + { + get { return reason; } + set + { + reason = ""; + reasonCode = 0; - if ((spaceIdx = value.IndexOf(' ')) <= 0) - spaceIdx = value.Length; - int.TryParse(value.Substring(0, spaceIdx), out this.reasonCode); - if (value.Length > spaceIdx + 3) - this.reason = value.Substring(spaceIdx + 3, value.Length - spaceIdx + 3); - } - } + if (string.IsNullOrEmpty(value)) + return; - /// - /// Get the reason code for disabling logging. - /// - public int ReasonCode - { - get { return this.reasonCode; } - } - - public LogChannelEvent(ManagerConnection source) - : base(source) - { - } - } + int spaceIdx; + + if ((spaceIdx = value.IndexOf(' ')) <= 0) + spaceIdx = value.Length; + int.TryParse(value.Substring(0, spaceIdx), out reasonCode); + if (value.Length > spaceIdx + 3) + reason = value.Substring(spaceIdx + 3, value.Length - spaceIdx + 3); + } + } + + /// + /// Get the reason code for disabling logging. + /// + public int ReasonCode + { + get { return reasonCode; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MasqueradeEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MasqueradeEvent.cs index 4844559..3f223c0 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MasqueradeEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MasqueradeEvent.cs @@ -1,43 +1,22 @@ -using System; - namespace AsterNET.Manager.Event { - class MasqueradeEvent : ManagerEvent - { - private string clone; - private string cloneState; - private string original; - private string originalState; + internal class MasqueradeEvent : ManagerEvent + { + public string Clone { get; set; } - public string Clone - { - get { return this.clone; } - set { this.clone = value; } - } + public string CloneState { get; set; } - public string CloneState - { - get { return this.cloneState; } - set { this.cloneState = value; } - } + public string Original { get; set; } - public string Original - { - get { return this.original; } - set { this.original = value; } - } + public string OriginalState { get; set; } - public string OriginalState - { - get { return this.originalState; } - set { this.originalState = value; } - } + #region Constructor - MasqueradeEvent(ManagerConnection source) - #region Constructor - MasqueradeEvent(ManagerConnection source) - public MasqueradeEvent(ManagerConnection source) - : base(source) - { - } - #endregion - } -} + public MasqueradeEvent(ManagerConnection source) + : base(source) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeJoinEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeJoinEvent.cs index f4cce70..7f51f5a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeJoinEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeJoinEvent.cs @@ -1,28 +1,18 @@ namespace AsterNET.Manager.Event { - /// - /// A MeetMeJoinEvent is triggered if a channel joins a meet me conference.
- /// It is implemented in apps/app_meetme.c - ///
- public class MeetmeJoinEvent : AbstractMeetmeEvent - { - private string callerIdNum; - private string callerIdName; + /// + /// A MeetMeJoinEvent is triggered if a channel joins a meet me conference.
+ /// It is implemented in apps/app_meetme.c + ///
+ public class MeetmeJoinEvent : AbstractMeetmeEvent + { + public MeetmeJoinEvent(ManagerConnection source) + : base(source) + { + } - public string CallerIdNum - { - get { return this.callerIdNum; } - set { this.callerIdNum = value; } - } - public string CallerIdName - { - get { return this.callerIdName; } - set { this.callerIdName = value; } - } + public string CallerIdNum { get; set; } - public MeetmeJoinEvent(ManagerConnection source) - : base(source) - { - } - } + public string CallerIdName { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeLeaveEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeLeaveEvent.cs index f112391..3fea20e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeLeaveEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeLeaveEvent.cs @@ -1,35 +1,20 @@ namespace AsterNET.Manager.Event { - /// - /// A MeetMeLeaveEvent is triggered if a channel leaves a meet me conference.
- /// It is implemented in apps/app_meetme.c - ///
- public class MeetmeLeaveEvent : AbstractMeetmeEvent - { - private string callerIdNum; - private string callerIdName; - private long duration; + /// + /// A MeetMeLeaveEvent is triggered if a channel leaves a meet me conference.
+ /// It is implemented in apps/app_meetme.c + ///
+ public class MeetmeLeaveEvent : AbstractMeetmeEvent + { + public MeetmeLeaveEvent(ManagerConnection source) + : base(source) + { + } - public string CallerIdNum - { - get { return this.callerIdNum; } - set { this.callerIdNum = value; } - } - public string CallerIdName - { - get { return this.callerIdName; } - set { this.callerIdName = value; } - } + public string CallerIdNum { get; set; } - public long Duration - { - get { return this.duration; } - set { this.duration = value; } - } + public string CallerIdName { get; set; } - public MeetmeLeaveEvent(ManagerConnection source) - : base(source) - { - } - } + public long Duration { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeMuteEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeMuteEvent.cs index 6bc8a9d..2126cbc 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeMuteEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeMuteEvent.cs @@ -1,18 +1,12 @@ namespace AsterNET.Manager.Event { - public class MeetmeMuteEvent : AbstractMeetmeEvent - { - private bool status; + public class MeetmeMuteEvent : AbstractMeetmeEvent + { + public MeetmeMuteEvent(ManagerConnection source) + : base(source) + { + } - public bool Status - { - get { return this.status; } - set { this.status = value; } - } - - public MeetmeMuteEvent(ManagerConnection source) - : base(source) - { - } - } + public bool Status { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkRequestEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkRequestEvent.cs index 4e1aa70..4179289 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkRequestEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkRequestEvent.cs @@ -1,18 +1,12 @@ namespace AsterNET.Manager.Event { - public class MeetmeTalkRequestEvent : AbstractMeetmeEvent - { - private bool status; + public class MeetmeTalkRequestEvent : AbstractMeetmeEvent + { + public MeetmeTalkRequestEvent(ManagerConnection source) + : base(source) + { + } - public bool Status - { - get { return this.status; } - set { this.status = value; } - } - - public MeetmeTalkRequestEvent(ManagerConnection source) - : base(source) - { - } - } + public bool Status { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkingEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkingEvent.cs index 49b3c8a..d4672bd 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkingEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MeetmeTalkingEvent.cs @@ -1,21 +1,15 @@ namespace AsterNET.Manager.Event { - /// - /// A MeetMeTalkingEvent is triggered when a user starts talking in a meet me conference. - /// - public class MeetmeTalkingEvent : AbstractMeetmeEvent - { - private bool status; + /// + /// A MeetMeTalkingEvent is triggered when a user starts talking in a meet me conference. + /// + public class MeetmeTalkingEvent : AbstractMeetmeEvent + { + public MeetmeTalkingEvent(ManagerConnection source) + : base(source) + { + } - public bool Status - { - get { return this.status; } - set { this.status = value; } - } - - public MeetmeTalkingEvent(ManagerConnection source) - : base(source) - { - } - } + public bool Status { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MessageWaitingEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MessageWaitingEvent.cs index e9a260d..54cea69 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MessageWaitingEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MessageWaitingEvent.cs @@ -1,53 +1,35 @@ namespace AsterNET.Manager.Event { - /// - /// A MessageWaitingEvent is triggered when someone leaves voicemail.
- /// It is implemented in apps/app_voicemail.c - ///
- public class MessageWaitingEvent : ManagerEvent - { - private string mailbox; - private int waiting; - private int newMessages; - private int oldMessages; + /// + /// A MessageWaitingEvent is triggered when someone leaves voicemail.
+ /// It is implemented in apps/app_voicemail.c + ///
+ public class MessageWaitingEvent : ManagerEvent + { + public MessageWaitingEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the name of the mailbox that has waiting messages.
- /// The name of the mailbox is of the form numberOfMailbox@context, e.g. 1234@default. - ///
- public string Mailbox - { - get { return this.mailbox; } - set { this.mailbox = value; } - } - /// - /// Get/Set the number of new messages in the mailbox. - /// - public int Waiting - { - get { return this.waiting; } - set { this.waiting = value; } - } - /// - /// Get/Set the number of new messages in this mailbox. - /// - public int New - { - get { return this.newMessages; } - set { this.newMessages = value; } - } - /// - /// Get/Set the number of old messages in this mailbox. - /// - public int Old - { - get { return this.oldMessages; } - set { this.oldMessages = value; } - } - - public MessageWaitingEvent(ManagerConnection source) - : base(source) - { - } - } + /// + /// Get/Set the name of the mailbox that has waiting messages.
+ /// The name of the mailbox is of the form numberOfMailbox@context, e.g. 1234@default. + ///
+ public string Mailbox { get; set; } + + /// + /// Get/Set the number of new messages in the mailbox. + /// + public int Waiting { get; set; } + + /// + /// Get/Set the number of new messages in this mailbox. + /// + public int New { get; set; } + + /// + /// Get/Set the number of old messages in this mailbox. + /// + public int Old { get; set; } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/MobileStatusEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/MobileStatusEvent.cs index 1931281..1cfd62c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/MobileStatusEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/MobileStatusEvent.cs @@ -1,27 +1,18 @@ -using System; - namespace AsterNET.Manager.Event { - public class MobileStatusEvent : ManagerEvent - { - private string status; - private string device; - public string Status - { - get { return status; } - set { status = value; } - } - public string Device - { - get { return device; } - set { device = value; } - } + public class MobileStatusEvent : ManagerEvent + { + public string Status { get; set; } - #region Constructor - MobileStatus(ManagerConnection source) - public MobileStatusEvent(ManagerConnection source) - : base(source) - { - } - #endregion - } -} + public string Device { get; set; } + + #region Constructor - MobileStatus(ManagerConnection source) + + public MobileStatusEvent(ManagerConnection source) + : base(source) + { + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/ModuleLoadReportEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/ModuleLoadReportEvent.cs index 8433dfe..0ab22f7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/ModuleLoadReportEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/ModuleLoadReportEvent.cs @@ -1,32 +1,16 @@ -using System; - namespace AsterNET.Manager.Event { - public class ModuleLoadReportEvent : ManagerEvent - { - private string moduleLoadStatus; - private string moduleSelection; - private int moduleCount; + public class ModuleLoadReportEvent : ManagerEvent + { + public ModuleLoadReportEvent(ManagerConnection source) + : base(source) + { + } - public string ModuleLoadStatus - { - get { return this.moduleLoadStatus; } - set { this.moduleLoadStatus = value; } - } - public string ModuleSelection - { - get { return this.moduleSelection; } - set { this.moduleSelection = value; } - } - public int ModuleCount - { - get { return this.moduleCount; } - set { this.moduleCount = value; } - } + public string ModuleLoadStatus { get; set; } - public ModuleLoadReportEvent(ManagerConnection source) - : base(source) - { - } - } -} + public string ModuleSelection { get; set; } + + public int ModuleCount { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/NewAccountCodeEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/NewAccountCodeEvent.cs index bfdfa4c..0c18c0a 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/NewAccountCodeEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/NewAccountCodeEvent.cs @@ -1,27 +1,14 @@ -using System; - namespace AsterNET.Manager.Event { - public class NewAccountCodeEvent : ManagerEvent - { - private string accountCode; - private string oldAccountCode; - - public string AccountCode - { - get { return this.accountCode; } - set { this.accountCode = value; } - } + public class NewAccountCodeEvent : ManagerEvent + { + public NewAccountCodeEvent(ManagerConnection source) + : base(source) + { + } - public string OldAccountCode - { - get { return this.oldAccountCode; } - set { this.oldAccountCode = value; } - } + public string AccountCode { get; set; } - public NewAccountCodeEvent(ManagerConnection source) - : base(source) - { - } - } -} + public string OldAccountCode { get; set; } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Event/NewCallerIdEvent.cs b/Asterisk.2013/Asterisk.NET/Manager/Event/NewCallerIdEvent.cs index 5773329..68fd025 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Event/NewCallerIdEvent.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Event/NewCallerIdEvent.cs @@ -1,84 +1,70 @@ using System; + namespace AsterNET.Manager.Event { - /// - /// A NewCallerIdEvent is triggered when the caller id of a channel changes.
- /// It is implemented in channel.c - ///
- public class NewCallerIdEvent : ManagerEvent - { - private string callerId; - private string callerIdNum; - private string callerIdName; - private string cidCallingPresTxt; - private int cidCallingPres; + /// + /// A NewCallerIdEvent is triggered when the caller id of a channel changes.
+ /// It is implemented in channel.c + ///
+ public class NewCallerIdEvent : ManagerEvent + { + private int cidCallingPres; + private string cidCallingPresTxt; - public NewCallerIdEvent(ManagerConnection source) - : base(source) - { - } + public NewCallerIdEvent(ManagerConnection source) + : base(source) + { + } - /// - /// Get/Set the new caller id. - /// - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - /// - /// Get/Set the new Caller*ID Name if set or "≶Unknown>" if none has been set. - /// - public string CallerIdName - { - get { return callerIdName; } - set { this.callerIdName = value; } - } - /// - /// Get/Set the new Caller*ID Numb. - /// - public string CallerIdNum - { - get { return callerIdNum; } - set { this.callerIdNum = value; } - } - /// - /// Get the CallerId presentation/screening. - /// - public int CidCallingPresNumeric - { - get { return cidCallingPres; } - } - - /// - /// Get/Sets the CallerId presentation/screening in the form "%d (%s)". - /// - public string CidCallingPres - { - get - { - return cidCallingPres.ToString() + " (" + cidCallingPresTxt + ")"; - } - set - { - string s = value; - if (s == null || s.Length == 0) - return; + /// + /// Get/Set the new caller id. + /// + public string CallerId { get; set; } - int spaceIdx = s.IndexOf(' '); - if (spaceIdx <= 0) - spaceIdx = s.Length; - try - { - this.cidCallingPres = int.Parse(s.Substring(0, spaceIdx)); - } - catch (FormatException) - { - return; - } - if (s.Length > spaceIdx + 3) - this.cidCallingPresTxt = s.Substring(spaceIdx + 2, (s.Length - 1) - (spaceIdx + 2)); - } - } - } + /// + /// Get/Set the new Caller*ID Name if set or "≶Unknown>" if none has been set. + /// + public string CallerIdName { get; set; } + + /// + /// Get/Set the new Caller*ID Numb. + /// + public string CallerIdNum { get; set; } + + /// + /// Get the CallerId presentation/screening. + /// + public int CidCallingPresNumeric + { + get { return cidCallingPres; } + } + + /// + /// Get/Sets the CallerId presentation/screening in the form "%d (%s)". + /// + public string CidCallingPres + { + get { return cidCallingPres + " (" + cidCallingPresTxt + ")"; } + set + { + string s = value; + if (s == null || s.Length == 0) + return; + + int spaceIdx = s.IndexOf(' '); + if (spaceIdx <= 0) + spaceIdx = s.Length; + try + { + cidCallingPres = int.Parse(s.Substring(0, spaceIdx)); + } + catch (FormatException) + { + return; + } + if (s.Length > spaceIdx + 3) + cidCallingPresTxt = s.Substring(spaceIdx + 2, (s.Length - 1) - (spaceIdx + 2)); + } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/IResponseHandler.cs b/Asterisk.2013/Asterisk.NET/Manager/IResponseHandler.cs index 1cc1a19..3804056 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/IResponseHandler.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/IResponseHandler.cs @@ -1,33 +1,24 @@ -using System; -using System.Collections.Generic; -using System.Text; using AsterNET.Manager.Action; +using AsterNET.Manager.Response; namespace AsterNET.Manager { - /// - /// An Interface to handle responses received from an asterisk server. - /// - /// - public interface IResponseHandler - { - /// - /// This method is called when a response is received. - /// - /// the response received - void HandleResponse(Response.ManagerResponse response); + /// + /// An Interface to handle responses received from an asterisk server. + /// + /// + public interface IResponseHandler + { + ManagerAction Action { get; } - void Free(); + int Hash { get; set; } - ManagerAction Action - { - get; - } + /// + /// This method is called when a response is received. + /// + /// the response received + void HandleResponse(ManagerResponse response); - int Hash - { - get; - set; - } - } -} + void Free(); + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/ManagerReader.cs b/Asterisk.2013/Asterisk.NET/Manager/ManagerReader.cs index fb46c64..b106b9c 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ManagerReader.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ManagerReader.cs @@ -1,71 +1,71 @@ using System; -using System.IO; using System.Collections; -using System.Threading; using System.Collections.Generic; using System.Net.Sockets; -using System.Text; +using System.Threading; using AsterNET.IO; +using AsterNET.Manager.Action; using AsterNET.Manager.Event; using AsterNET.Manager.Response; namespace AsterNET.Manager { - /// - /// Default implementation of the ManagerReader interface. + /// Default implementation of the ManagerReader interface. /// public class ManagerReader { #if LOGGER - private Logger logger = Logger.Instance(); + private readonly Logger logger = Logger.Instance(); #endif - private ManagerConnection mrConnector; + private readonly ManagerConnection mrConnector; private SocketConnection mrSocket; - private bool die = false; - private bool is_logoff = false; - private bool disconnect = false; + private bool die; + private bool is_logoff; + private bool disconnect; private byte[] lineBytes; private string lineBuffer; - private Queue lineQueue; + private readonly Queue lineQueue; private ResponseHandler pingHandler; private bool processingCommandResult; private bool wait4identiier; private DateTime lastPacketTime; - Dictionary packet; - List commandList; + private readonly Dictionary packet; + private readonly List commandList; #region ManagerReader(dispatcher, asteriskServer) + /// - /// Creates a new ManagerReader. + /// Creates a new ManagerReader. /// /// the dispatcher to use for dispatching events and responses. public ManagerReader(ManagerConnection connection) { - this.mrConnector = connection; - this.die = false; + mrConnector = connection; + die = false; lineQueue = new Queue(); packet = new Dictionary(); commandList = new List(); } + #endregion #region Socket + /// - /// Sets the socket to use for reading from the asterisk server. + /// Sets the socket to use for reading from the asterisk server. /// - internal IO.SocketConnection Socket + internal SocketConnection Socket { - set - { - this.mrSocket = value; - } + set { mrSocket = value; } } + #endregion #region Die + internal bool Die { get { return die; } @@ -73,27 +73,31 @@ namespace AsterNET.Manager { die = value; if (die) - this.mrSocket = null; + mrSocket = null; } } + #endregion #region IsLogoff + internal bool IsLogoff { set { is_logoff = value; } } + #endregion #region mrReaderCallbback(IAsyncResult ar) - /// + + //// /// Async Read callback /// /// IAsyncResult private void mrReaderCallbback(IAsyncResult ar) { // mreader = Mr.Reader - ManagerReader mrReader = (ManagerReader)ar.AsyncState; + var mrReader = (ManagerReader) ar.AsyncState; if (mrReader.die) return; @@ -119,7 +123,7 @@ namespace AsterNET.Manager if (count == 0) { // No received data - it's may be DISCONNECT !!! - if(!is_logoff) + if (!is_logoff) disconnect = true; return; } @@ -128,11 +132,13 @@ namespace AsterNET.Manager int idx; // \n - because not all dev in Digium use \r\n // .Trim() kill \r - lock (((ICollection)lineQueue).SyncRoot) + lock (((ICollection) lineQueue).SyncRoot) while (!string.IsNullOrEmpty(mrReader.lineBuffer) && (idx = mrReader.lineBuffer.IndexOf("\n")) >= 0) { line = idx > 0 ? mrReader.lineBuffer.Substring(0, idx).Trim() : string.Empty; - mrReader.lineBuffer = (idx + 1 < mrReader.lineBuffer.Length ? mrReader.lineBuffer.Substring(idx + 1) : string.Empty); + mrReader.lineBuffer = (idx + 1 < mrReader.lineBuffer.Length + ? mrReader.lineBuffer.Substring(idx + 1) + : string.Empty); lineQueue.Enqueue(line); } // Give a next portion !!! @@ -153,9 +159,11 @@ namespace AsterNET.Manager mrReader.mrSocket = null; } } + #endregion #region Reinitialize + internal void Reinitialize() { mrSocket.Initial = false; @@ -171,17 +179,19 @@ namespace AsterNET.Manager mrSocket.NetworkStream.BeginRead(lineBytes, 0, lineBytes.Length, mrReaderCallbback, this); lastPacketTime = DateTime.Now; } + #endregion #region Run() - /// + + //// /// Reads line by line from the asterisk server, sets the protocol identifier as soon as it is /// received and dispatches the received events and responses via the associated dispatcher. /// /// /// /// - internal void Run() + internal void Run() { if (mrSocket == null) throw new SystemException("Unable to run: socket is null."); @@ -195,6 +205,7 @@ namespace AsterNET.Manager while (!die) { #region check line from * + if (!is_logoff) { if (mrSocket != null && mrSocket.Initial) @@ -209,30 +220,30 @@ namespace AsterNET.Manager } if (lineQueue.Count == 0) { - if (lastPacketTime.AddMilliseconds(mrConnector.PingInterval) < DateTime.Now - && mrConnector.PingInterval > 0 - && mrSocket != null - && !wait4identiier - && !is_logoff - ) - { - if (pingHandler != null) - { - if (pingHandler.Response == null) - { - // If one PingInterval from Ping without Pong then send Disconnect event - mrConnector.RemoveResponseHandler(pingHandler); - mrConnector.DispatchEvent(new DisconnectEvent(mrConnector)); - } - pingHandler.Free(); - pingHandler = null; + if (lastPacketTime.AddMilliseconds(mrConnector.PingInterval) < DateTime.Now + && mrConnector.PingInterval > 0 + && mrSocket != null + && !wait4identiier + && !is_logoff + ) + { + if (pingHandler != null) + { + if (pingHandler.Response == null) + { + // If one PingInterval from Ping without Pong then send Disconnect event + mrConnector.RemoveResponseHandler(pingHandler); + mrConnector.DispatchEvent(new DisconnectEvent(mrConnector)); + } + pingHandler.Free(); + pingHandler = null; } else { // Send PING to * try { - pingHandler = new ResponseHandler(new Action.PingAction(), null); + pingHandler = new ResponseHandler(new PingAction(), null); mrConnector.SendAction(pingHandler.Action, pingHandler); } catch @@ -247,50 +258,51 @@ namespace AsterNET.Manager continue; } + #endregion lastPacketTime = DateTime.Now; - lock (((ICollection)lineQueue).SyncRoot) + lock (((ICollection) lineQueue).SyncRoot) line = lineQueue.Dequeue().Trim(); #if LOGGER logger.Debug(line); #endif + #region processing Response: Follows + if (processingCommandResult) { if (line == "--END COMMAND--") { - Response.CommandResponse commandResponse = new Response.CommandResponse(); + var commandResponse = new CommandResponse(); Helper.SetAttributes(commandResponse, packet); commandResponse.Result = commandList; processingCommandResult = false; packet.Clear(); mrConnector.DispatchResponse(commandResponse); - continue; } + string lineLower = line.ToLower(Helper.CultureInfo); + if (lineLower.StartsWith("privilege: ") + || lineLower.StartsWith("actionid: ") + || lineLower.StartsWith("timestamp: ") + || lineLower.StartsWith("server: ") + ) + Helper.AddKeyValue(packet, line); else - { - string lineLower = line.ToLower(Helper.CultureInfo); - if (lineLower.StartsWith("privilege: ") - || lineLower.StartsWith("actionid: ") - || lineLower.StartsWith("timestamp: ") - || lineLower.StartsWith("server: ") - ) - Helper.AddKeyValue(packet, line); - else - commandList.Add(line); - } + commandList.Add(line); continue; } + #endregion #region collect key: value and ProtocolIdentifier + if (!string.IsNullOrEmpty(line)) { if (wait4identiier && line.StartsWith("Asterisk Call Manager")) { wait4identiier = false; - ConnectEvent connectEvent = new ConnectEvent(mrConnector); + var connectEvent = new ConnectEvent(mrConnector); connectEvent.ProtocolIdentifier = line; mrConnector.DispatchEvent(connectEvent); continue; @@ -307,6 +319,7 @@ namespace AsterNET.Manager Helper.AddKeyValue(packet, line); continue; } + #endregion #region process events and responses @@ -321,7 +334,7 @@ namespace AsterNET.Manager packet.Clear(); } - if(mrSocket != null) + if (mrSocket != null) mrSocket.Close(); break; } @@ -344,6 +357,7 @@ namespace AsterNET.Manager mrConnector.DispatchEvent(new DisconnectEvent(mrConnector)); } } + #endregion } -} +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Originate.cs b/Asterisk.2013/Asterisk.NET/Manager/Originate.cs index 0c909d9..e80ed6e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Originate.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Originate.cs @@ -1,179 +1,215 @@ -using System; -using System.Text; -using System.Collections; using System.Collections.Generic; namespace AsterNET.Manager { - public class Originate - { - private string channel; - private string exten; - private string context; - private int priority; - private long timeout; - private string callerId; - private Dictionary variables; - private string account; - private string application; - private string data; + public class Originate + { + private string account; + private string application; + private string callerId; + private string channel; + private string context; + private string data; + private string exten; + private int priority; + private long timeout; + private Dictionary variables; - #region Account - /// - /// Get/Set the account code to use for the originated call. - /// The account code is included in the call detail record generated for this - /// call and will be used for billing. - /// - public string Account - { - get { return account; } - set { this.account = value; } - } - #endregion - #region CallerId - /// - /// Get/Set the caller id to set on the outgoing channel. - /// - public string CallerId - { - get { return callerId; } - set { this.callerId = value; } - } - #endregion - #region Channel - /// - /// Get/Set the name of the channel to connect to the outgoing call. - /// This property is required. - /// - public string Channel - { - get { return channel; } - set { this.channel = value; } - } - #endregion - #region Context - /// - /// Get/Set the name of the context of the extension to connect to. - /// If you set the context you also have to set the exten and priority properties. - /// - public string Context - { - get { return context; } - set { this.context = value; } - } - #endregion - #region Exten - /// - /// Get/Set the extension to connect to. - /// If you set the extension you also have to set the context and priority properties. - /// - public string Exten - { - get { return exten; } - set { this.exten = value; } - } - #endregion - #region Priority - /// - /// Get/Set the priority of the extension to connect to. If you set the priority - /// you also have to set the context and exten properties. - /// - public int Priority - { - get { return priority; } - set { this.priority = value; } - } - #endregion - #region Application - /// - /// Get/Set the name of the application to connect to. - /// - public string Application - { - get { return application; } - set { this.application = value; } - } - #endregion - #region Data - /// - /// Get/Set the parameters to pass to the application. - /// - public string Data - { - get { return data; } - set { this.data = value; } - } - #endregion - #region Timeout - /// - /// Get/Set the timeout for the origination (in seconds) for the origination.
- /// The channel must be answered within this time, otherwise the origination - /// is considered to have failed and an OriginateFailureEvent is generated.
- /// If not set, a default value of 30 seconds. - ///
- public long Timeout - { - get { return timeout / 1000; } - set { this.timeout = value * 1000; } - } - #endregion + #region Account - #region Variable - /// - /// Get/Set the variables to set on the originated call.
- /// Variable assignments are of the form "VARNAME=VALUE". You can specify - /// multiple variable assignments separated by the '|' character.
- /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def". - ///
- public string Variable - { - get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); } - set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); } - } - #endregion + /// + /// Get/Set the account code to use for the originated call. + /// The account code is included in the call detail record generated for this + /// call and will be used for billing. + /// + public string Account + { + get { return account; } + set { this.account = value; } + } - #region GetVariables() - /// - /// Get the variables dictionary to set on the originated call. - /// - public Dictionary GetVariables() - { - return variables; - } - #endregion - #region SetVariables(IDictionary vars) - /// - /// Set the variables dictionary to set on the originated call. - /// - public void SetVariables(Dictionary vars) - { - this.variables = vars; - } - #endregion - #region GetVariable(string name, string val) - /// - /// Gets a variable on the originated call. Replaces any existing variable with the same name. - /// - public string GetVariable(string key) - { - if (variables == null) - return string.Empty; - return variables[key]; - } - #endregion - #region SetVariable(string name, string val) - /// - /// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. - /// - public void SetVariable(string key, string value) - { - if (variables == null) - variables = new Dictionary(); - if (variables.ContainsKey(key)) - variables[key] = value; - else - variables.Add(key, value); - } - #endregion - } + #endregion + + #region CallerId + + /// + /// Get/Set the caller id to set on the outgoing channel. + /// + public string CallerId + { + get { return callerId; } + set { this.callerId = value; } + } + + #endregion + + #region Channel + + /// + /// Get/Set the name of the channel to connect to the outgoing call. + /// This property is required. + /// + public string Channel + { + get { return channel; } + set { this.channel = value; } + } + + #endregion + + #region Context + + /// + /// Get/Set the name of the context of the extension to connect to. + /// If you set the context you also have to set the exten and priority properties. + /// + public string Context + { + get { return context; } + set { this.context = value; } + } + + #endregion + + #region Exten + + /// + /// Get/Set the extension to connect to. + /// If you set the extension you also have to set the context and priority properties. + /// + public string Exten + { + get { return exten; } + set { this.exten = value; } + } + + #endregion + + #region Priority + + /// + /// Get/Set the priority of the extension to connect to. If you set the priority + /// you also have to set the context and exten properties. + /// + public int Priority + { + get { return priority; } + set { this.priority = value; } + } + + #endregion + + #region Application + + /// + /// Get/Set the name of the application to connect to. + /// + public string Application + { + get { return application; } + set { this.application = value; } + } + + #endregion + + #region Data + + /// + /// Get/Set the parameters to pass to the application. + /// + public string Data + { + get { return data; } + set { this.data = value; } + } + + #endregion + + #region Timeout + + /// + /// Get/Set the timeout for the origination (in seconds) for the origination.
+ /// The channel must be answered within this time, otherwise the origination + /// is considered to have failed and an OriginateFailureEvent is generated.
+ /// If not set, a default value of 30 seconds. + ///
+ public long Timeout + { + get { return timeout/1000; } + set { this.timeout = value*1000; } + } + + #endregion + + #region Variable + + /// + /// Get/Set the variables to set on the originated call.
+ /// Variable assignments are of the form "VARNAME=VALUE". You can specify + /// multiple variable assignments separated by the '|' character.
+ /// Example: "VAR1=abc|VAR2=def" sets the channel variables VAR1 to "abc" and VAR2 to "def". + ///
+ public string Variable + { + get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); } + set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); } + } + + #endregion + + #region GetVariables() + + /// + /// Get the variables dictionary to set on the originated call. + /// + public Dictionary GetVariables() + { + return variables; + } + + #endregion + + #region SetVariables(IDictionary vars) + + /// + /// Set the variables dictionary to set on the originated call. + /// + public void SetVariables(Dictionary vars) + { + this.variables = vars; + } + + #endregion + + #region GetVariable(string name, string val) + + /// + /// Gets a variable on the originated call. Replaces any existing variable with the same name. + /// + public string GetVariable(string key) + { + if (variables == null) + return string.Empty; + return variables[key]; + } + + #endregion + + #region SetVariable(string name, string val) + + /// + /// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. + /// + public void SetVariable(string key, string value) + { + if (variables == null) + variables = new Dictionary(); + if (variables.ContainsKey(key)) + variables[key] = value; + else + variables.Add(key, value); + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/ChallengeResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/ChallengeResponse.cs index 61c504d..066507b 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/ChallengeResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/ChallengeResponse.cs @@ -1,21 +1,22 @@ namespace AsterNET.Manager.Response { - /// - /// Corresponds to a ChallengeAction and contains the challenge needed to log in using challenge/response. - /// - /// - /// - public class ChallengeResponse : ManagerResponse - { - private string challenge; - /// - /// Get/Set the challenge to use when creating the key for log in. - /// - /// - public string Challenge - { - get { return challenge; } - set { this.challenge = value; } - } - } -} + /// + /// Corresponds to a ChallengeAction and contains the challenge needed to log in using challenge/response. + /// + /// + /// + public class ChallengeResponse : ManagerResponse + { + private string challenge; + + /// + /// Get/Set the challenge to use when creating the key for log in. + /// + /// + public string Challenge + { + get { return challenge; } + set { this.challenge = value; } + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/CommandResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/CommandResponse.cs index c367bd0..7ba2ece 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/CommandResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/CommandResponse.cs @@ -1,27 +1,26 @@ -using System.Collections; using System.Collections.Generic; namespace AsterNET.Manager.Response { - /// - /// Corresponds to a CommandAction.
- /// Asterisk's handling of the command action is generelly quite hairy. - /// It sends a "Response: Follows" line followed by the raw output of the command including empty lines. - /// At the end of the command output a line containing "--END COMMAND--" is sent. - /// The reader parses this response into a CommandResponse object to hide these details. - ///
- /// - public class CommandResponse : ManagerResponse - { - protected internal List result; + /// + /// Corresponds to a CommandAction.
+ /// Asterisk's handling of the command action is generelly quite hairy. + /// It sends a "Response: Follows" line followed by the raw output of the command including empty lines. + /// At the end of the command output a line containing "--END COMMAND--" is sent. + /// The reader parses this response into a CommandResponse object to hide these details. + ///
+ /// + public class CommandResponse : ManagerResponse + { + protected internal List result; - /// - /// Get/Set a List containing strings representing the lines returned by the CLI command. - /// - public List Result - { - get { return result; } - set { this.result = value; } - } - } + /// + /// Get/Set a List containing strings representing the lines returned by the CLI command. + /// + public List Result + { + get { return result; } + set { this.result = value; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/ExtensionStateResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/ExtensionStateResponse.cs index 9be9e18..8e77474 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/ExtensionStateResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/ExtensionStateResponse.cs @@ -1,33 +1,34 @@ -using System.Text; - namespace AsterNET.Manager.Response { - public class ExtensionStateResponse : ManagerResponse - { - private string exten; - private string context; - private string hint; - private int status; + public class ExtensionStateResponse : ManagerResponse + { + private string context; + private string exten; + private string hint; + private int status; - public string Exten - { - get { return exten; } - set { this.exten = value; } - } - public string Context - { - get { return context; } - set { this.context = value; } - } - public string Hint - { - get { return hint; } - set { this.hint = value; } - } - public int Status - { - get { return status; } - set { this.status = value; } - } - } -} + public string Exten + { + get { return exten; } + set { this.exten = value; } + } + + public string Context + { + get { return context; } + set { this.context = value; } + } + + public string Hint + { + get { return hint; } + set { this.hint = value; } + } + + public int Status + { + get { return status; } + set { this.status = value; } + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/GetConfigResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/GetConfigResponse.cs index 58a9b7d..28af93e 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/GetConfigResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/GetConfigResponse.cs @@ -1,113 +1,111 @@ -using System; using System.Collections.Generic; -using System.Text; namespace AsterNET.Manager.Response { - /// - /// Response that is received when sending a GetConfigAction.
- /// Asterisk's response to the GetConfig command is ugly, and requires some - /// parsing of attributes. This class lazily parses its own attributes to hide - /// the ugly details. If the file requested exists but does not contain at least - /// a line with a category, the ResponseBuilder won't create an instance of - /// GetConfigResponse, as it won't know what the empty response is. - ///
- public class GetConfigResponse : ManagerResponse - { - private Dictionary categories; - private Dictionary> lines; + /// + /// Response that is received when sending a GetConfigAction.
+ /// Asterisk's response to the GetConfig command is ugly, and requires some + /// parsing of attributes. This class lazily parses its own attributes to hide + /// the ugly details. If the file requested exists but does not contain at least + /// a line with a category, the ResponseBuilder won't create an instance of + /// GetConfigResponse, as it won't know what the empty response is. + ///
+ public class GetConfigResponse : ManagerResponse + { + private Dictionary categories; + private Dictionary> lines; - /// - /// Get the map of category numbers to category names. - /// - public Dictionary Categories - { - get - { - if (categories == null) - { - categories = new Dictionary(); - lines = new Dictionary>(); - if (attributes != null) - foreach (string key in attributes.Keys) - { - string keyLower = key.ToLower(Helper.CultureInfo); - if (keyLower.StartsWith("category-")) - { - string[] parts = key.Split(Common.MINUS_SEPARATOR); - if (parts.Length < 2) - continue; + /// + /// Get the map of category numbers to category names. + /// + public Dictionary Categories + { + get + { + if (categories == null) + { + categories = new Dictionary(); + lines = new Dictionary>(); + if (attributes != null) + foreach (string key in attributes.Keys) + { + string keyLower = key.ToLower(Helper.CultureInfo); + if (keyLower.StartsWith("category-")) + { + string[] parts = key.Split(Common.MINUS_SEPARATOR); + if (parts.Length < 2) + continue; - int categoryNumber; - if (!int.TryParse(parts[1], out categoryNumber)) - continue; - categories.Add(categoryNumber, attributes[key]); - continue; - } - if (keyLower.StartsWith("line-")) - { - string[] parts = key.Split(Common.MINUS_SEPARATOR); - if (parts.Length < 3) - continue; + int categoryNumber; + if (!int.TryParse(parts[1], out categoryNumber)) + continue; + categories.Add(categoryNumber, attributes[key]); + continue; + } + if (keyLower.StartsWith("line-")) + { + string[] parts = key.Split(Common.MINUS_SEPARATOR); + if (parts.Length < 3) + continue; - int categoryNumber; - if (!int.TryParse(parts[1], out categoryNumber)) - continue; + int categoryNumber; + if (!int.TryParse(parts[1], out categoryNumber)) + continue; - int lineNumber; - if (!int.TryParse(parts[2], out lineNumber)) - continue; - if (!lines.ContainsKey(categoryNumber)) - lines.Add(categoryNumber, new Dictionary()); + int lineNumber; + if (!int.TryParse(parts[2], out lineNumber)) + continue; + if (!lines.ContainsKey(categoryNumber)) + lines.Add(categoryNumber, new Dictionary()); - if(lines[categoryNumber].ContainsKey(lineNumber)) - lines[categoryNumber][lineNumber] = attributes[key]; - else - lines[categoryNumber].Add(lineNumber, attributes[key]); - } - } - } - return categories; - } - } + if (lines[categoryNumber].ContainsKey(lineNumber)) + lines[categoryNumber][lineNumber] = attributes[key]; + else + lines[categoryNumber].Add(lineNumber, attributes[key]); + } + } + } + return categories; + } + } - /// - /// Returns the map of line number to line value for a given category. - /// - /// a valid category number from getCategories. - /// - public Dictionary Lines(int category) - { - if (lines == null) - { - lines = new Dictionary>(); - if (attributes != null) - foreach (string key in attributes.Keys) - if (key.ToLower(Helper.CultureInfo).StartsWith("line-")) - { - string[] parts = key.Split(Common.MINUS_SEPARATOR); - if (parts.Length < 3) - continue; + /// + /// Returns the map of line number to line value for a given category. + /// + /// a valid category number from getCategories. + /// + public Dictionary Lines(int category) + { + if (lines == null) + { + lines = new Dictionary>(); + if (attributes != null) + foreach (string key in attributes.Keys) + if (key.ToLower(Helper.CultureInfo).StartsWith("line-")) + { + string[] parts = key.Split(Common.MINUS_SEPARATOR); + if (parts.Length < 3) + continue; - int categoryNumber; - if (!int.TryParse(parts[1], out categoryNumber)) - continue; + int categoryNumber; + if (!int.TryParse(parts[1], out categoryNumber)) + continue; - int lineNumber; - if (!int.TryParse(parts[2], out lineNumber)) - continue; - if (!lines.ContainsKey(categoryNumber)) - lines.Add(categoryNumber, new Dictionary()); + int lineNumber; + if (!int.TryParse(parts[2], out lineNumber)) + continue; + if (!lines.ContainsKey(categoryNumber)) + lines.Add(categoryNumber, new Dictionary()); - if (lines[categoryNumber].ContainsKey(lineNumber)) - lines[categoryNumber][lineNumber] = attributes[key]; - else - lines[categoryNumber].Add(lineNumber, attributes[key]); - } - } - if (lines.ContainsKey(category)) - return lines[category]; - return new Dictionary(); - } - } -} + if (lines[categoryNumber].ContainsKey(lineNumber)) + lines[categoryNumber][lineNumber] = attributes[key]; + else + lines[categoryNumber].Add(lineNumber, attributes[key]); + } + } + if (lines.ContainsKey(category)) + return lines[category]; + return new Dictionary(); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxCountResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxCountResponse.cs index da8b65c..5aa9115 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxCountResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxCountResponse.cs @@ -1,39 +1,41 @@ namespace AsterNET.Manager.Response { - /// - /// A MailboxCountResponse is sent in response to a MailboxCountAction and contains the number of old - /// and new messages in a mailbox. - /// - /// - public class MailboxCountResponse:ManagerResponse - { - private string mailbox; - private int newMessages; - private int oldMessages; + /// + /// A MailboxCountResponse is sent in response to a MailboxCountAction and contains the number of old + /// and new messages in a mailbox. + /// + /// + public class MailboxCountResponse : ManagerResponse + { + private string mailbox; + private int newMessages; + private int oldMessages; - /// - /// Get/Set the name of the mailbox. - /// - public string Mailbox - { - get { return mailbox; } - set { this.mailbox = value; } - } - /// - /// Get/Set the number of new messages in the mailbox. - /// - public int NewMessages - { - get { return newMessages; } - set { this.newMessages = value; } - } - /// - /// Returns the number of old messages in the mailbox. - /// - public int OldMessages - { - get { return oldMessages; } - set { this.oldMessages = value; } - } - } + /// + /// Get/Set the name of the mailbox. + /// + public string Mailbox + { + get { return mailbox; } + set { this.mailbox = value; } + } + + /// + /// Get/Set the number of new messages in the mailbox. + /// + public int NewMessages + { + get { return newMessages; } + set { this.newMessages = value; } + } + + /// + /// Returns the number of old messages in the mailbox. + /// + public int OldMessages + { + get { return oldMessages; } + set { this.oldMessages = value; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxStatusResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxStatusResponse.cs index 11974b7..e3dd1f7 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxStatusResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/MailboxStatusResponse.cs @@ -1,32 +1,34 @@ namespace AsterNET.Manager.Response { - /// - /// A MailboxStatusResponse is sent in response to a MailboxStatusAction and indicates if a set - /// of mailboxes contains waiting messages. - /// - /// - public class MailboxStatusResponse:ManagerResponse - { - /// The name of the mailbox. - private string mailbox; - /// Indicates if there are new messages waiting in the given set of mailboxes. - private bool waiting; + /// + /// A MailboxStatusResponse is sent in response to a MailboxStatusAction and indicates if a set + /// of mailboxes contains waiting messages. + /// + /// + public class MailboxStatusResponse : ManagerResponse + { + /// The name of the mailbox. + private string mailbox; - /// - /// Get/Set the names of the mailboxes, separated by ",". - /// - public string Mailbox - { - get { return mailbox; } - set { this.mailbox = value; } - } - /// - /// Get/Set true if at least one of the given mailboxes contains new messages, false otherwise. - /// - public bool Waiting - { - get { return waiting; } - set { this.waiting = value; } - } - } + /// Indicates if there are new messages waiting in the given set of mailboxes. + private bool waiting; + + /// + /// Get/Set the names of the mailboxes, separated by ",". + /// + public string Mailbox + { + get { return mailbox; } + set { this.mailbox = value; } + } + + /// + /// Get/Set true if at least one of the given mailboxes contains new messages, false otherwise. + /// + public bool Waiting + { + get { return waiting; } + set { this.waiting = value; } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerError.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerError.cs index d21a878..12368e3 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerError.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerError.cs @@ -1,22 +1,22 @@ -using System.Collections; using System.Collections.Generic; namespace AsterNET.Manager.Response { - /// - /// Represents an "Response: Error" response received from the asterisk server. - /// The cause for the error is given in the message attribute. - /// - public class ManagerError : ManagerResponse - { - /// Creates a new ManagerError. - public ManagerError() - : base() - { - } - public ManagerError(Dictionary attributes) - : base(attributes) - { - } - } + /// + /// Represents an "Response: Error" response received from the asterisk server. + /// The cause for the error is given in the message attribute. + /// + public class ManagerError : ManagerResponse + { + /// Creates a new ManagerError. + public ManagerError() + : base() + { + } + + public ManagerError(Dictionary attributes) + : base(attributes) + { + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerResponse.cs index 1e603ae..2b54c44 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/ManagerResponse.cs @@ -1,217 +1,242 @@ using System; -using System.Text; -using System.Collections; using System.Collections.Generic; namespace AsterNET.Manager.Response { - /// - /// Represents a response received from the Asterisk server as the result of a - /// previously sent ManagerAction.
- /// The response can be linked with the action that caused it by looking the - /// action id attribute that will match the action id of the corresponding - /// action. - ///
- public class ManagerResponse : IParseSupport - { - private DateTime dateReceived; - private string privilege; - private string actionId; - private string response; - private string message; - private string uniqueId; - private string server; - protected Dictionary attributes; + /// + /// Represents a response received from the Asterisk server as the result of a + /// previously sent ManagerAction.
+ /// The response can be linked with the action that caused it by looking the + /// action id attribute that will match the action id of the corresponding + /// action. + ///
+ public class ManagerResponse : IParseSupport + { + private string actionId; + protected Dictionary attributes; + private DateTime dateReceived; + private string message; + private string privilege; + private string response; + private string server; + private string uniqueId; - #region Constructor - ManagerEvent() - public ManagerResponse() - { - this.dateReceived = DateTime.Now; - } - public ManagerResponse(Dictionary attributes) - : this() - { - Helper.SetAttributes(this, attributes); - } + #region Constructor - ManagerEvent() - #endregion + public ManagerResponse() + { + this.dateReceived = DateTime.Now; + } + public ManagerResponse(Dictionary attributes) + : this() + { + Helper.SetAttributes(this, attributes); + } - #region Attributes - /// - /// Store all unknown (without setter) keys from manager event.
- /// Use in default Parse method . - ///
- public Dictionary Attributes - { - get { return attributes; } - } - #endregion + #endregion - #region Server - /// - /// Specify a server to which to send your commands (x.x.x.x or hostname).
- /// This should match the server name specified in your config file's "host" entry. - /// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations. - ///
- public string Server - { - get { return this.server; } - set { this.server = value; } - } - #endregion + #region Attributes - #region DateReceived - /// - /// Get/Set the point in time this response was received from the asterisk server. - /// - public DateTime DateReceived - { - get { return dateReceived; } - set { this.dateReceived = value; } - } - #endregion + /// + /// Store all unknown (without setter) keys from manager event.
+ /// Use in default Parse method . + ///
+ public Dictionary Attributes + { + get { return attributes; } + } - #region Privilege - /// - /// Get/Set the AMI authorization class of this event.
- /// This is one or more of system, call, log, verbose, command, agent or user. - /// Multiple privileges are separated by comma.
- /// Note: This property is not available from Asterisk 1.0 servers. - ///
- public string Privilege - { - get { return privilege; } - set { this.privilege = value; } - } - #endregion + #endregion - #region ActionId - /// - /// Get/Set the action id received with this response referencing the action that generated this response. - /// - public string ActionId - { - get { return actionId; } - set { this.actionId = value; } - } - #endregion + #region Server - #region Message - /// - /// Get/Set the message received with this response.
- /// The content depends on the action that generated this response. - ///
- public string Message - { - get { return message; } - set { this.message = value; } - } - #endregion + /// + /// Specify a server to which to send your commands (x.x.x.x or hostname).
+ /// This should match the server name specified in your config file's "host" entry. + /// If you do not specify a server, the proxy will pick the first one it finds -- fine in single-server configurations. + ///
+ public string Server + { + get { return this.server; } + set { this.server = value; } + } - #region Response - /// - /// Get/Set the value of the "Response:" line.
- /// This typically a String like "Success" or "Error" but depends on the action that generated this response. - ///
- public string Response - { - get { return response; } - set { this.response = value; } - } - #endregion + #endregion - #region UniqueId - /// - /// Get/Set the unique id received with this response.
- /// The unique id is used to keep track of channels created by the action sent, for example an OriginateAction. - ///
- public string UniqueId - { - get { return uniqueId; } - set { this.uniqueId = value; } - } - #endregion + #region DateReceived + /// + /// Get/Set the point in time this response was received from the asterisk server. + /// + public DateTime DateReceived + { + get { return dateReceived; } + set { this.dateReceived = value; } + } - #region IsSuccess() - /// - /// Return true if Response is success - /// - /// - public bool IsSuccess() - { - return response == "Success"; - } - #endregion + #endregion - #region GetAttribute(string key) - /// - /// Returns the value of the attribute with the given key.
- /// This is particulary important when a response contains special - /// attributes that are dependent on the action that has been sent.
- /// An example of this is the response to the GetVarAction. - /// It contains the value of the channel variable as an attribute - /// stored under the key of the variable name.
- /// Example: - ///
-		/// GetVarAction action = new GetVarAction();
-		/// action.setChannel("SIP/1310-22c3");
-		/// action.setVariable("ALERT_INFO");
-		/// ManagerResponse response = connection.SendAction(action);
-		/// String alertInfo = response.getAttribute("ALERT_INFO");
-		/// 
- /// As all attributes are internally stored in lower case the key is - /// automatically converted to lower case before lookup. - ///
- /// the key to lookup. - /// the value of the attribute stored under this key or - /// null if there is no such attribute. - /// - public string GetAttribute(string key) - { - return (string) attributes[key.ToLower(Helper.CultureInfo)]; - } - #endregion + #region Privilege - #region Parse(string key, string value) - /// - /// Unknown properties parser - /// - /// key name - /// key value - /// true - value parsed, false - can't parse value - public virtual bool Parse(string key, string value) - { - if (attributes == null) - attributes = new Dictionary(); + /// + /// Get/Set the AMI authorization class of this event.
+ /// This is one or more of system, call, log, verbose, command, agent or user. + /// Multiple privileges are separated by comma.
+ /// Note: This property is not available from Asterisk 1.0 servers. + ///
+ public string Privilege + { + get { return privilege; } + set { this.privilege = value; } + } - if (attributes.ContainsKey(key)) - // Key already presents, add with delimiter - attributes[key] += string.Concat(Common.LINE_SEPARATOR, value); - else - attributes.Add(key, value); - return true; - } - #endregion + #endregion - #region ParseSpecial(Dictionary attributes) - /// - /// Unknown properties parser - /// - /// dictionary - /// updated dictionary - public virtual Dictionary ParseSpecial(Dictionary attributes) - { - return attributes; - } - #endregion + #region ActionId - #region ToString() - public override string ToString() - { - return Helper.ToString(this); - } - #endregion - } -} + /// + /// Get/Set the action id received with this response referencing the action that generated this response. + /// + public string ActionId + { + get { return actionId; } + set { this.actionId = value; } + } + + #endregion + + #region Message + + /// + /// Get/Set the message received with this response.
+ /// The content depends on the action that generated this response. + ///
+ public string Message + { + get { return message; } + set { this.message = value; } + } + + #endregion + + #region Response + + /// + /// Get/Set the value of the "Response:" line.
+ /// This typically a String like "Success" or "Error" but depends on the action that generated this response. + ///
+ public string Response + { + get { return response; } + set { this.response = value; } + } + + #endregion + + #region UniqueId + + /// + /// Get/Set the unique id received with this response.
+ /// The unique id is used to keep track of channels created by the action sent, for example an OriginateAction. + ///
+ public string UniqueId + { + get { return uniqueId; } + set { this.uniqueId = value; } + } + + #endregion + + #region IsSuccess() + + /// + /// Return true if Response is success + /// + /// + public bool IsSuccess() + { + return response == "Success"; + } + + #endregion + + #region GetAttribute(string key) + + /// + /// Returns the value of the attribute with the given key.
+ /// This is particulary important when a response contains special + /// attributes that are dependent on the action that has been sent.
+ /// An example of this is the response to the GetVarAction. + /// It contains the value of the channel variable as an attribute + /// stored under the key of the variable name.
+ /// Example: + ///
+        ///         GetVarAction action = new GetVarAction();
+        ///         action.setChannel("SIP/1310-22c3");
+        ///         action.setVariable("ALERT_INFO");
+        ///         ManagerResponse response = connection.SendAction(action);
+        ///         String alertInfo = response.getAttribute("ALERT_INFO");
+        ///     
+ /// As all attributes are internally stored in lower case the key is + /// automatically converted to lower case before lookup. + ///
+ /// the key to lookup. + /// + /// the value of the attribute stored under this key or + /// null if there is no such attribute. + /// + public string GetAttribute(string key) + { + return (string) attributes[key.ToLower(Helper.CultureInfo)]; + } + + #endregion + + #region Parse(string key, string value) + + /// + /// Unknown properties parser + /// + /// key name + /// key value + /// true - value parsed, false - can't parse value + public virtual bool Parse(string key, string value) + { + if (attributes == null) + attributes = new Dictionary(); + + if (attributes.ContainsKey(key)) + // Key already presents, add with delimiter + attributes[key] += string.Concat(Common.LINE_SEPARATOR, value); + else + attributes.Add(key, value); + return true; + } + + #endregion + + #region ParseSpecial(Dictionary attributes) + + /// + /// Unknown properties parser + /// + /// dictionary + /// updated dictionary + public virtual Dictionary ParseSpecial(Dictionary attributes) + { + return attributes; + } + + #endregion + + #region ToString() + + public override string ToString() + { + return Helper.ToString(this); + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/Response/OriginateResponse.cs b/Asterisk.2013/Asterisk.NET/Manager/Response/OriginateResponse.cs index 8b928aa..3ae6b50 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/Response/OriginateResponse.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/Response/OriginateResponse.cs @@ -1,110 +1,131 @@ using System; -using System.Text; namespace AsterNET.Manager.Response { - public class OriginateResponse - { - private string uniqueId; - private int reason; - private string channel; - private string channelName; - private string response; + public class OriginateResponse + { + private string channel; + private string channelName; + private DateTime endTime = DateTime.MinValue; + private int reason; + private string response; - private DateTime startTime; - private DateTime endTime = DateTime.MinValue; + private DateTime startTime; + private string uniqueId; - #region IsSuccess - public bool IsSuccess - { - get { return response == "Success"; } - } - #endregion + #region IsSuccess - #region UniqueId - public string UniqueId - { - get { return uniqueId; } - set { this.uniqueId = value; } - } - #endregion + public bool IsSuccess + { + get { return response == "Success"; } + } - #region Channel - public string Channel - { - get { return channel; } - set { this.channel = value; } - } - #endregion + #endregion - #region ChannelName - public string ChannelName - { - get { return channelName; } - set { this.channelName = value; } - } - #endregion + #region UniqueId - #region Reason - public int Reason - { - get { return reason; } - set { this.reason = value; } - } - #endregion + public string UniqueId + { + get { return uniqueId; } + set { this.uniqueId = value; } + } - #region Response - public string Response - { - get { return response; } - set { response = value; } - } - #endregion + #endregion - #region StartTime - public DateTime StartTime - { - get { return startTime; } - set { this.startTime = value; } - } - #endregion + #region Channel - #region EndTime - public DateTime EndTime - { - get { return endTime; } - set { this.endTime = value; } - } - #endregion + public string Channel + { + get { return channel; } + set { this.channel = value; } + } - #region Constructor - Call() - public OriginateResponse() - { - startTime = DateTime.Now; - } - #endregion + #endregion - #region CalcDuration() - /// - /// Return the duration of the call in milliseconds. If the call is has not - /// ended, the duration so far is calculated. - /// - public long CalcDuration() - { - DateTime compTime; - if (endTime != DateTime.MinValue) - compTime = endTime; - else - compTime = DateTime.Now; - return (compTime.Ticks - startTime.Ticks) / 10000; - } - #endregion + #region ChannelName - #region ToString() - public override string ToString() - { - return Helper.ToString(this); - } - #endregion - } + public string ChannelName + { + get { return channelName; } + set { this.channelName = value; } + } + + #endregion + + #region Reason + + public int Reason + { + get { return reason; } + set { this.reason = value; } + } + + #endregion + + #region Response + + public string Response + { + get { return response; } + set { response = value; } + } + + #endregion + + #region StartTime + + public DateTime StartTime + { + get { return startTime; } + set { this.startTime = value; } + } + + #endregion + + #region EndTime + + public DateTime EndTime + { + get { return endTime; } + set { this.endTime = value; } + } + + #endregion + + #region Constructor - Call() + + public OriginateResponse() + { + startTime = DateTime.Now; + } + + #endregion + + #region CalcDuration() + + /// + /// Return the duration of the call in milliseconds. If the call is has not + /// ended, the duration so far is calculated. + /// + public long CalcDuration() + { + DateTime compTime; + if (endTime != DateTime.MinValue) + compTime = endTime; + else + compTime = DateTime.Now; + return (compTime.Ticks - startTime.Ticks)/10000; + } + + #endregion + + #region ToString() + + public override string ToString() + { + return Helper.ToString(this); + } + + #endregion + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/ResponseEventHandler.cs b/Asterisk.2013/Asterisk.NET/Manager/ResponseEventHandler.cs index d047b27..2ada508 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ResponseEventHandler.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ResponseEventHandler.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using System.Threading; using AsterNET.Manager.Action; using AsterNET.Manager.Event; @@ -8,84 +5,84 @@ using AsterNET.Manager.Response; namespace AsterNET.Manager { - /// - /// A combinded event and response handler that adds received events and the response to a ResponseEvents object. - /// - public class ResponseEventHandler : IResponseHandler - { - private ManagerConnection connection; - private AutoResetEvent autoEvent; - private ResponseEvents events; - private ManagerActionEvent action; - private int hash; + /// + /// A combinded event and response handler that adds received events and the response to a ResponseEvents object. + /// + public class ResponseEventHandler : IResponseHandler + { + private ManagerActionEvent action; + private AutoResetEvent autoEvent; + private ManagerConnection connection; + private ResponseEvents events; + private int hash; - /// - /// Creates a new instance. - /// - /// the ResponseEvents to store the events in - /// the type of event that indicates that all events have been received - /// the thread to interrupt when the actionCompleteEventClass has been received - public ResponseEventHandler(ManagerConnection connection, ManagerActionEvent action, AutoResetEvent autoEvent) - { - this.connection = connection; - this.events = new ResponseEvents(); - this.action = action; - this.autoEvent = autoEvent; - } + /// + /// Creates a new instance. + /// + /// the ResponseEvents to store the events in + /// the type of event that indicates that all events have been received + /// the thread to interrupt when the actionCompleteEventClass has been received + public ResponseEventHandler(ManagerConnection connection, ManagerActionEvent action, AutoResetEvent autoEvent) + { + this.connection = connection; + this.events = new ResponseEvents(); + this.action = action; + this.autoEvent = autoEvent; + } - public ManagerAction Action - { - get { return action; } - } + public ResponseEvents ResponseEvents + { + get { return events; } + } - public ResponseEvents ResponseEvents - { - get { return events; } - } + public ManagerAction Action + { + get { return action; } + } - public int Hash - { - get { return hash; } - set { hash = value; } - } + public int Hash + { + get { return hash; } + set { hash = value; } + } - public void Free() - { - connection = null; - autoEvent = null; - action = null; - events.Events.Clear(); - events.Response = null; - events = null; - } + public void Free() + { + connection = null; + autoEvent = null; + action = null; + events.Events.Clear(); + events.Response = null; + events = null; + } - public void HandleEvent(ManagerEvent e) - { - // should always be a ResponseEvent, anyway... - if (e is Event.ResponseEvent) - { - ResponseEvent responseEvent = (ResponseEvent)e; - events.AddEvent(responseEvent); - } + public void HandleResponse(ManagerResponse response) + { + events.Response = response; + if (response is ManagerError) + events.Complete = true; - // finished? - if (action.ActionCompleteEventClass().IsAssignableFrom(e.GetType())) - { - lock (events) - events.Complete = true; - if (events.Response != null) - autoEvent.Set(); - } - } + if (events.Complete && autoEvent != null) + autoEvent.Set(); + } - public void HandleResponse(ManagerResponse response) - { - events.Response = response; - if (response is ManagerError) - events.Complete = true; + public void HandleEvent(ManagerEvent e) + { + // should always be a ResponseEvent, anyway... + if (e is ResponseEvent) + { + var responseEvent = (ResponseEvent) e; + events.AddEvent(responseEvent); + } - if (events.Complete && autoEvent != null) - autoEvent.Set(); - } - } -} + // finished? + if (action.ActionCompleteEventClass().IsAssignableFrom(e.GetType())) + { + lock (events) + events.Complete = true; + if (events.Response != null) + autoEvent.Set(); + } + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/ResponseEvents.cs b/Asterisk.2013/Asterisk.NET/Manager/ResponseEvents.cs index 3c07608..0d2b1db 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ResponseEvents.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ResponseEvents.cs @@ -1,55 +1,46 @@ using System.Collections; -using AsterNET.Manager.Response; -using AsterNET.Manager.Event; using System.Collections.Generic; +using AsterNET.Manager.Event; +using AsterNET.Manager.Response; namespace AsterNET.Manager { - /// - /// Collection of ResponseEvent. Use in events generation actions. - /// - public class ResponseEvents - { - private ManagerResponse response; - private List events; - private bool complete; + /// + /// Collection of ResponseEvent. Use in events generation actions. + /// + public class ResponseEvents + { + private readonly List events; - public ManagerResponse Response - { - get { return this.response; } - set { this.response = value; } - } + /// Creates a new instance. + public ResponseEvents() + { + events = new List(); + Complete = false; + } - public List Events - { - get { return events; } - } - /// - /// Indicats if all events have been received. - /// - public bool Complete - { - get { return this.complete; } - set { this.complete = value; } - } + public ManagerResponse Response { get; set; } - /// Creates a new instance. - public ResponseEvents() - { - this.events = new List(); - this.complete = false; - } - - /// - /// Adds a ResponseEvent that has been received. - /// - /// the ResponseEvent that has been received. - public void AddEvent(ResponseEvent e) - { - lock (((IList)events).SyncRoot) - { - events.Add(e); - } - } - } + public List Events + { + get { return events; } + } + + /// + /// Indicats if all events have been received. + /// + public bool Complete { get; set; } + + /// + /// Adds a ResponseEvent that has been received. + /// + /// the ResponseEvent that has been received. + public void AddEvent(ResponseEvent e) + { + lock (((IList) events).SyncRoot) + { + events.Add(e); + } + } + } } \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Manager/ResponseHandler.cs b/Asterisk.2013/Asterisk.NET/Manager/ResponseHandler.cs index fc9dc7d..a0f1013 100644 --- a/Asterisk.2013/Asterisk.NET/Manager/ResponseHandler.cs +++ b/Asterisk.2013/Asterisk.NET/Manager/ResponseHandler.cs @@ -1,60 +1,59 @@ -using System; using System.Threading; using AsterNET.Manager.Action; using AsterNET.Manager.Response; namespace AsterNET.Manager { - /// - /// A simple response handler that stores the received response in a ResponseHandlerResult for further processing. - /// - public class ResponseHandler : IResponseHandler - { - private ManagerResponse response; - private AutoResetEvent autoEvent; - private ManagerAction action; - private int hash; + /// + /// A simple response handler that stores the received response in a ResponseHandlerResult for further processing. + /// + public class ResponseHandler : IResponseHandler + { + private ManagerAction action; + private AutoResetEvent autoEvent; + private int hash; + private ManagerResponse response; - /// - /// Creates a new instance. - /// - /// the result to store the response in - /// the thread to interrupt when the response has been received - public ResponseHandler(ManagerAction action, AutoResetEvent autoEvent) - { - this.response = null; - this.action = action; - this.autoEvent = autoEvent; - } + /// + /// Creates a new instance. + /// + /// the result to store the response in + /// the thread to interrupt when the response has been received + public ResponseHandler(ManagerAction action, AutoResetEvent autoEvent) + { + response = null; + this.action = action; + this.autoEvent = autoEvent; + } - public ManagerAction Action - { - get { return this.action; } - } + public ManagerResponse Response + { + get { return this.response; } + } - public ManagerResponse Response - { - get { return this.response; } - } + public ManagerAction Action + { + get { return this.action; } + } - public int Hash - { - get { return hash; } - set { hash = value; } - } + public int Hash + { + get { return hash; } + set { hash = value; } + } - public void Free() - { - autoEvent = null; - action = null; - response = null; - } + public void Free() + { + autoEvent = null; + action = null; + response = null; + } - public virtual void HandleResponse(ManagerResponse response) - { - this.response = response; - if(autoEvent != null) - this.autoEvent.Set(); - } - } -} + public virtual void HandleResponse(ManagerResponse response) + { + this.response = response; + if (autoEvent != null) + this.autoEvent.Set(); + } + } +} \ No newline at end of file diff --git a/Asterisk.2013/Asterisk.NET/Util/MD5Support.cs b/Asterisk.2013/Asterisk.NET/Util/MD5Support.cs index 856a1b0..10eb56f 100644 --- a/Asterisk.2013/Asterisk.NET/Util/MD5Support.cs +++ b/Asterisk.2013/Asterisk.NET/Util/MD5Support.cs @@ -1,98 +1,101 @@ -using System; using System.Security.Cryptography; namespace AsterNET.Util { - /// - /// Encapsulates the functionality of message digest algorithms such as SHA-1 or MD5. - /// - public class MD5Support - { - private HashAlgorithm algorithm; - private byte[] data = new byte[0]; - private int position; - private string algorithmName; + /// + /// Encapsulates the functionality of message digest algorithms such as SHA-1 or MD5. + /// + public class MD5Support + { + private readonly HashAlgorithm _algorithm; + private int _position; + private byte[] data = new byte[0]; - /// - /// Creates a message digest using the specified name to set Algorithm property. - /// - /// The name of the algorithm to use - public MD5Support(string algorithm) - { - if (algorithm.Equals("SHA-1")) - this.algorithmName = "SHA"; - else - this.algorithmName = algorithm; - this.algorithm = (HashAlgorithm)CryptoConfig.CreateFromName(this.algorithmName); - this.data = new byte[0]; - this.position = 0; - } + /// + /// Creates a message digest using the specified name to set Algorithm property. + /// + /// The name of the algorithm to use + public MD5Support(string algorithm) + { + var algorithmName = algorithm.Equals("SHA-1") ? "SHA" : algorithm; + _algorithm = (HashAlgorithm) CryptoConfig.CreateFromName(algorithmName); + data = new byte[0]; + _position = 0; + } - #region DigestData - /// - /// Computes the hash value for the internal data digest. - /// - /// The array of signed bytes with the resulting hash value - public sbyte[] DigestData - { - get - { - byte[] bytes = this.algorithm.ComputeHash(this.data); - sbyte[] sbytes = new sbyte[bytes.Length]; - for (int i = 0; i < bytes.Length; i++) - sbytes[i] = (sbyte)bytes[i]; - this.data = null; - this.position = 0; - return sbytes; - } - } - #endregion + #region DigestData - #region Update - /// - /// Updates the digest data with the specified array of bytes by making an append - /// operation in the internal array of data. - /// - /// The array of bytes for the update operation - public void Update(byte[] newData) - { - if (position == 0) - { - this.data = newData; - this.position = this.data.Length - 1; - } - else - { - byte[] oldData = this.data; - this.data = new byte[newData.Length + position + 1]; - oldData.CopyTo(this.data, 0); - newData.CopyTo(this.data, oldData.Length); - this.position = this.data.Length - 1; - } - } - #endregion + /// + /// Computes the hash value for the internal data digest. + /// + /// The array of signed bytes with the resulting hash value + public sbyte[] DigestData + { + get + { + var bytes = _algorithm.ComputeHash(data); + var sbytes = new sbyte[bytes.Length]; + for (var i = 0; i < bytes.Length; i++) + sbytes[i] = (sbyte) bytes[i]; + data = null; + _position = 0; + return sbytes; + } + } - #region GetInstance - /// - /// Generates a new instance of the MessageDigestSupport class using the specified algorithm - /// - /// The name of the algorithm to use - /// A new instance of the MessageDigestSupport class - public static MD5Support GetInstance(string algorithm) - { - return new MD5Support(algorithm); - } - #endregion + #endregion - #region GetInstance - /// - /// Generates a new instance of the MessageDigestSupport class using the specified algorithm - /// - /// A new instance of the MD5 algorithm class - public static MD5Support GetInstance() - { - return new MD5Support("MD5"); - } - #endregion - } -} + #region Update + + /// + /// Updates the digest data with the specified array of bytes by making an append + /// operation in the internal array of data. + /// + /// The array of bytes for the update operation + public void Update(byte[] newData) + { + if (_position == 0) + { + data = newData; + _position = data.Length - 1; + } + else + { + var oldData = data; + data = new byte[newData.Length + _position + 1]; + oldData.CopyTo(data, 0); + newData.CopyTo(data, oldData.Length); + _position = data.Length - 1; + } + } + + #endregion + + #region GetInstance + + /// + /// Generates a new instance of the MessageDigestSupport class using the specified algorithm + /// + /// The name of the algorithm to use + /// A new instance of the MessageDigestSupport class + public static MD5Support GetInstance(string algorithm) + { + return new MD5Support(algorithm); + } + + #endregion + + #region GetInstance + + /// + /// Generates a new instance of the MessageDigestSupport class using the specified algorithm + /// + /// A new instance of the MD5 algorithm class + public static MD5Support GetInstance() + { + return new MD5Support("MD5"); + } + + #endregion + } +} \ No newline at end of file diff --git a/Asterisk.2013/ChangeLog.txt b/Asterisk.2013/ChangeLog.txt index 030abab..5201c99 100644 --- a/Asterisk.2013/ChangeLog.txt +++ b/Asterisk.2013/ChangeLog.txt @@ -1,3 +1,6 @@ +03.01.2015 (Skrusty) + Code tidy, comments cleaned up,moved to auto properties, using's cleaned up + 28.10.2014 (skrusty) added support for Asterisk 13 in version parser in ManagerConnection.cs and AsteriskVersion.cs