Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 12151 discussions
[commit] r8245 - in freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk: EventWatcher FreeSwitchEventSocket FreeSwitchEventSocket/ChannelEvents FreeSwitchEventSocket/Commands FreeSwitchEventSocket/Events FreeSwitchEventSocket/Ivr IvrSocket
by Freeswitch SVN 02 May '08
by Freeswitch SVN 02 May '08
02 May '08
Author: verifier
Date: Fri May 2 07:23:27 2008
New Revision: 8245
Added:
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendEventCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/DtmfEventArgs.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrQueue.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/PrivateWaitDtmf.cs
Modified:
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs
Log:
Been working on the IvrInterface.
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs Fri May 2 07:23:27 2008
@@ -222,20 +222,20 @@
{
GetVariableReply gvr = (GetVariableReply) reply;
if (!gvr.Success)
- Debug.WriteLine("OnBridgeCallId " + reply.ErrCode);
+ Debug.WriteLine("OnBridgeCallId " + reply.ErrorMessage);
string otherChannelId = (string) command.ContextData;
SetVariable sv = new SetVariable(otherChannelId, "gate_callid", gvr.Value);
- sv.OnReply += OnCallIdReply;
+ sv.ReplyReceived += OnCallIdReply;
_eventMgr.Send(sv);
- command.OnReply -= OnBridgeCallId;
+ command.ReplyReceived -= OnBridgeCallId;
}
private void OnCallIdReply(CmdBase command, CommandReply reply)
{
if (!reply.Success)
- Debug.WriteLine("OnCallIdReply " + reply.ErrCode);
- command.OnReply -= OnCallIdReply;
+ Debug.WriteLine("OnCallIdReply " + reply.ErrorMessage);
+ command.ReplyReceived -= OnCallIdReply;
}
#region Nested type: ExtensionMapper
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs Fri May 2 07:23:27 2008
@@ -1,10 +1,32 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
namespace FreeSwitch.EventSocket
{
public class EventChannelExecute : EventChannelState
{
+ private string _appName;
+ private string _arguments;
+
+ public string AppName
+ {
+ get { return _appName; }
+ set { _appName = value; }
+ }
+
+ public string Arguments
+ {
+ get { return _arguments; }
+ set { _arguments = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "application")
+ AppName = value;
+ else if (name == "application-data")
+ Arguments = value;
+ else
+ return base.ParseCommand(name, value);
+
+ return true;
+ }
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs Fri May 2 07:23:27 2008
@@ -2,6 +2,32 @@
{
public class EventChannelExecuteComplete : EventChannelState
{
+ private string _appName;
+ private string _arguments;
+
+ public string AppName
+ {
+ get { return _appName; }
+ set { _appName = value; }
+ }
+
+ public string Arguments
+ {
+ get { return _arguments; }
+ set { _arguments = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "application")
+ AppName = value;
+ else if (name == "application-data")
+ Arguments = value;
+ else
+ return base.ParseCommand(name, value);
+
+ return true;
+ }
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs Fri May 2 07:23:27 2008
@@ -28,7 +28,7 @@
else
{
CommandReply reply = new CommandReply(false);
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs Fri May 2 07:23:27 2008
@@ -26,7 +26,7 @@
else
{
CommandReply reply = new CommandReply(false);
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs Fri May 2 07:23:27 2008
@@ -8,7 +8,7 @@
public abstract class CmdBase
{
- public event ReplyHandler OnReply;
+ public event ReplyHandler ReplyReceived;
private object _contextData;
@@ -35,16 +35,21 @@
public virtual void HandleReply(CommandReply reply)
{
// a command is only invoked once.
- if (OnReply != null)
+ if (ReplyReceived != null)
{
- OnReply(this, reply);
- OnReply = null;
+ ReplyReceived(this, reply);
+ ReplyReceived = null;
}
}
public virtual CommandReply CreateReply(string dataToParse)
{
- return null;
+ if (string.IsNullOrEmpty(dataToParse.Trim()))
+ return new CommandReply(false);
+
+ CommandReply reply = new CommandReply(dataToParse.Trim()[0] == '+');
+ reply.ErrorMessage = dataToParse;
+ return reply;
}
public override string ToString()
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs Fri May 2 07:23:27 2008
@@ -6,7 +6,7 @@
public class CommandReply
{
private bool _success;
- private string _errCode;
+ private string _ErrorMessage;
public CommandReply(bool success)
{
@@ -18,10 +18,10 @@
get { return _success; }
}
- public string ErrCode
+ public string ErrorMessage
{
- get { return _errCode; }
- set { _errCode = value; }
+ get { return _ErrorMessage; }
+ set { _ErrorMessage = value; }
}
public override string ToString()
@@ -29,7 +29,7 @@
if (_success)
return "Success";
else
- return "Failed: " + _errCode;
+ return "Failed: " + _ErrorMessage;
}
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs Fri May 2 07:23:27 2008
@@ -47,7 +47,7 @@
else
{
CommandReply reply = new CommandReply(false);
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs Fri May 2 07:23:27 2008
@@ -39,7 +39,7 @@
else
{
GetVariableReply reply = new GetVariableReply(false, string.Empty);
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs Fri May 2 07:23:27 2008
@@ -97,9 +97,9 @@
{
OriginateReply reply = new OriginateReply(false, string.Empty);
if (nameValue.Length > 1)
- reply.ErrCode = nameValue[1];
+ reply.ErrorMessage = nameValue[1];
else
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs Fri May 2 07:23:27 2008
@@ -6,6 +6,7 @@
public class PlaybackCmd : SendMsg
{
private readonly string _fileName;
+ private readonly string _dtmfAbort = string.Empty;
/// <summary>
///
@@ -21,6 +22,12 @@
_fileName = fileName;
}
+ public PlaybackCmd(string uuid, string fileName, string dtmfAbort) : base(uuid)
+ {
+ _fileName = fileName;
+ _dtmfAbort = dtmfAbort;
+ }
+
public override string Command
{
get { return "playback"; }
@@ -30,5 +37,10 @@
{
get { return _fileName; }
}
+
+ public string DtmfAbort
+ {
+ get { return _dtmfAbort; }
+ }
}
}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendEventCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendEventCmd.cs Fri May 2 07:23:27 2008
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class SendEventCmd : CmdBase
+ {
+ private EventBase _event;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="evt">Note that all events have NOT being developed to be sent, only to be received.</param>
+ public SendEventCmd(EventBase evt)
+ {
+ _event = evt;
+ }
+
+
+ public override string Command
+ {
+ get { return "sendevent " + _event.Name + "\n"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _event.ToString(); }
+ }
+ }
+}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs Fri May 2 07:23:27 2008
@@ -25,7 +25,17 @@
public override string Arguments
{
- get { return _channelId + " " + _name + " " + _value; }
+ get { return _channelId + " " + Name + " " + Value; }
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ public string Value
+ {
+ get { return _value; }
}
public override CommandReply CreateReply(string dataToParse)
@@ -35,7 +45,7 @@
else
{
CommandReply reply = new CommandReply(false);
- reply.ErrCode = dataToParse;
+ reply.ErrorMessage = dataToParse;
return reply;
}
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs Fri May 2 07:23:27 2008
@@ -79,7 +79,6 @@
}
catch (SocketException)
{
- Console.WriteLine("EventSocket: Connect failed");
HandleDisconnect();
}
}
@@ -88,8 +87,6 @@
{
lock (_lockobj)
{
- Console.WriteLine("EventSocket.TryConnect: Connecting to " + _hostName + ":" + _port);
-
_socket.Connect(_hostName, _port);
if (_stream == null)
_stream = new NetworkStream(_socket, false);
@@ -167,9 +164,7 @@
{
try
{
- Console.WriteLine("EventSocket.Write: Trying to connect eventsocket.");
TryConnect();
- Console.WriteLine("EventSocket.Write: Connected.");
}
catch (SocketException)
{
@@ -189,7 +184,7 @@
if (msg.ContentType == "auth/request")
{
AuthCommand cmd = new AuthCommand(_password);
- cmd.OnReply += OnAuthed;
+ cmd.ReplyReceived += OnAuthed;
_commands.Enqueue(cmd);
Write(cmd + "\n\n");
}
@@ -199,7 +194,6 @@
if (_commands.Count > 0)
{
CmdBase cmd = _commands.Dequeue();
- Console.WriteLine("Reply to " + cmd.GetType().Name + ": " + msg.Body);
cmd.HandleReply(cmd.CreateReply(msg.Body));
}
else
@@ -285,14 +279,11 @@
EventSocket client = (EventSocket) state;
try
{
- Console.WriteLine("EventSocket.Timer: Trying to connect eventsocket.");
client.TryConnect();
Console.WriteLine("EventSocket.Timer: Connected.");
}
- catch (SocketException err)
- {
- Console.WriteLine("Eventsocket.TryConnect: " + err.Message);
- }
+ catch (SocketException)
+ {}
}
}
}
\ No newline at end of file
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs Fri May 2 07:23:27 2008
@@ -19,7 +19,27 @@
public string Name
{
- get { return m_name; }
+ get
+ {
+ lock (this)
+ {
+ if (string.IsNullOrEmpty(m_name))
+ {
+ string name = GetType().Name.Substring(5); //remove (Event)
+ m_name = string.Empty;
+ m_name += char.ToUpper(name[0]);
+ for (int i = 1; i < name.Length; ++i)
+ {
+ if (char.IsUpper(name[i]))
+ m_name += '_';
+ else
+ m_name += char.ToUpper(name[i]);
+ }
+ }
+ }
+
+ return m_name;
+ }
set { m_name = value; }
}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs Fri May 2 07:23:27 2008
@@ -8,6 +8,18 @@
private int _totalMessages;
private int _totalUrgentMessages;
+ public EventMessageWaiting()
+ {
+
+ }
+
+ public EventMessageWaiting(string account, int newMessages, int totalMessages)
+ {
+ _account = account;
+ _newMessages = newMessages;
+ _totalMessages = totalMessages;
+ }
+
/// <summary>
/// Messages are for this account
/// </summary>
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj Fri May 2 07:23:27 2008
@@ -35,10 +35,6 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="Tiny.Net, Version=1.0.0.1, Culture=neutral, PublicKeyToken=15480ee9e0247fcb, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\..\dlls\Debug\Tiny.Net.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ChannelEvents\EventChannelApplication.cs" />
@@ -65,12 +61,16 @@
<Compile Include="Commands\ParkCmd.cs" />
<Compile Include="Commands\Playback.cs" />
<Compile Include="Commands\RecordCmd.cs" />
+ <Compile Include="Commands\SendEventCmd.cs" />
<Compile Include="Commands\SendMsg.cs" />
<Compile Include="Commands\SetVariable.cs" />
<Compile Include="Commands\SleepCmd.cs" />
<Compile Include="EventManager.cs" />
<Compile Include="ChannelEvents\EventDtmfStatus.cs" />
+ <Compile Include="Ivr\DtmfEventArgs.cs" />
<Compile Include="Ivr\IvrInterface.cs" />
+ <Compile Include="Ivr\IvrQueue.cs" />
+ <Compile Include="Ivr\PrivateWaitDtmf.cs" />
<Compile Include="PlainEventMsg.cs" />
<Compile Include="EventParser.cs" />
<Compile Include="Events.cs" />
@@ -118,6 +118,7 @@
</Target>
-->
<PropertyGroup>
- <PostBuildEvent>copy $(TargetPath) $(SolutionDir)..\..\dlls\$(ConfigurationName)</PostBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
</PropertyGroup>
</Project>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/DtmfEventArgs.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/DtmfEventArgs.cs Fri May 2 07:23:27 2008
@@ -0,0 +1,44 @@
+using System;
+
+namespace FreeSwitch.EventSocket.Ivr
+{
+
+ public class DtmfEventArgs : EventArgs
+ {
+ private string _dtmf;
+ private string _dtmfCopy;
+
+ public DtmfEventArgs(string dtmf)
+ {
+ _dtmf = dtmf;
+ _dtmfCopy = (string)_dtmf.Clone();
+ }
+
+ /// <summary>
+ /// You cannot remove digits from the buffer (since it's a copy of the real buffer).
+ /// </summary>
+ /// <seealso cref="RemoveDigits"/>
+ public string Dtmf
+ {
+ get { return _dtmfCopy; }
+ }
+
+ /// <summary>
+ /// Remove digits from the real buffer.
+ /// </summary>
+ /// <param name="count">number of digits to remove.</param>
+ public void RemoveDigits(int count)
+ {
+ lock (_dtmf)
+ {
+ if (count > _dtmf.Length)
+ _dtmf = string.Empty;
+ else
+ _dtmf = _dtmf.Remove(0, count);
+ _dtmfCopy = (string)_dtmf.Clone();
+ }
+ }
+ }
+
+ public delegate void DtmfHandler(object source, DtmfEventArgs args);
+}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs Fri May 2 07:23:27 2008
@@ -8,16 +8,19 @@
{
public const string AllDigits = "*#0123456789";
private readonly string _uuid;
- private readonly string _baseSoundPath = "sounds\\";
+ private string _baseSoundPath = "sounds\\";
private string _dtmf = string.Empty;
private EventManager _mgr;
public event DtmfHandler DtmfReceived;
- private readonly int _dtmfWaitCount = 0;
- private ManualResetEvent _dtmfWaitEvent;
+ private int _dtmfWaitCount = 0;
private bool _abortSpeechOnDtmf;
private bool _answered;
private IvrInterfaceHandler _handler = null;
private string _lastAbortDigits = "*";
+ private int _defaultTimeout = 10000;
+ private readonly ManualResetEvent _dtmfTimeout = new ManualResetEvent(false);
+ private IvrQueue _queue;
+
public IvrInterface(EventManager mgr, string uuid)
{
@@ -26,6 +29,7 @@
if (string.IsNullOrEmpty(uuid))
throw new ArgumentNullException("uuid");
+ _queue = new IvrQueue(mgr);
_mgr = mgr;
mgr.EventReceived += OnEvent;
_uuid = uuid;
@@ -54,34 +58,64 @@
set { _abortSpeechOnDtmf = value; }
}
+ /// <summary>
+ /// True if IVR call have been answered.
+ /// </summary>
public bool Answered
{
get { return _answered; }
}
+ /// <summary>
+ /// Number of seconds to wait on DTMF
+ /// </summary>
+ public int DefaultTimeout
+ {
+ get { return _defaultTimeout; }
+ set { _defaultTimeout = value; }
+ }
+
+ /// <summary>
+ /// Relative path under FreeSWITCH to where the sound files resides
+ /// </summary>
+ /// <remarks>default is "sounds\"</remarks>
+ public string BaseSoundPath
+ {
+ get { return _baseSoundPath; }
+ set { _baseSoundPath = value; }
+ }
+
private void OnEvent(EventBase receivedEvent)
{
+ if (!receivedEvent.IsChannelEvent)
+ return;
+
+ ChannelEvent channelEvent = (ChannelEvent) receivedEvent;
+ if (channelEvent.UniqueId != _uuid)
+ return;
+
if (receivedEvent is EventChannelAnswer)
{
_answered = true;
}
-/* else if (receivedEvent is EventDtmfStatus)
- {
- // Let's always dequeue dtmf.
- EventDtmfStatus evt = (EventDtmfStatus) receivedEvent;
- if (evt.UniqueId == _uuid)
- _mgr.Send(new GetDtmfCmd(_uuid, evt.Count));
- }*/
else if (receivedEvent is EventDtmf)
{
EventDtmf evt = (EventDtmf) receivedEvent;
- lock (_dtmf)
- _dtmf += evt.Digit;
- if (_dtmfWaitCount >= _dtmf.Length)
- _dtmfWaitEvent.Set();
+ Console.WriteLine("DTMF Event: " + evt.Digit);
+ if (_queue.GotDtmf(evt.Digit))
+ {
+ lock (_dtmf)
+ _dtmf += evt.Digit;
+
+ if (_dtmfWaitCount != 0 && _dtmf.Length >= _dtmfWaitCount)
+ {
+ Console.WriteLine("Got all DTMF: " + _dtmfWaitCount + "/" + _dtmf.Length);
+ _dtmfTimeout.Set();
+ }
- if (DtmfReceived != null)
- DtmfReceived(this, new DtmfEventArgs(_dtmf));
+ if (DtmfReceived != null)
+ DtmfReceived(this, new DtmfEventArgs(_dtmf));
+ }
}
else if (receivedEvent is EventChannelDestroy || receivedEvent is EventChannelHangup)
{
@@ -91,6 +125,16 @@
_mgr = null;
}
}
+ else if (receivedEvent is EventChannelExecute)
+ {
+ EventChannelExecute exec = (EventChannelExecute)receivedEvent;
+ _queue.Execute(exec);
+ }
+ else if (receivedEvent is EventChannelExecuteComplete)
+ {
+ EventChannelExecuteComplete exec = (EventChannelExecuteComplete)receivedEvent;
+ _queue.ExecuteComplete(exec);
+ }
}
/// <summary>
@@ -104,15 +148,26 @@
{
if (_mgr == null)
return string.Empty;
- if (_dtmfWaitEvent != null)
- throw new InvalidOperationException("Already waiting on an event.");
+
+ lock (_dtmf)
+ {
+ if (_dtmfWaitCount > 0)
+ throw new InvalidOperationException("Already waiting on an event.");
+ _dtmfWaitCount = 1;
+ _dtmfTimeout.Reset();
+ }
if (_dtmf.Length < count)
{
- _dtmfWaitEvent = new ManualResetEvent(false);
- if (!_dtmfWaitEvent.WaitOne(timeout * 1000, true))
+ if (_queue.CommandRunning)
+ _queue.Add(new PrivateWaitDtmf(OnDtmfTimeout, timeout));
+
+ _dtmfWaitCount = count - _dtmf.Length;
+ if (!_dtmfTimeout.WaitOne(timeout, true))
{
+ Console.WriteLine("Didn't get any DTMF: " + _dtmf);
_dtmf = string.Empty;
+ _dtmfWaitCount = 0;
return string.Empty;
}
}
@@ -122,14 +177,54 @@
if (_dtmf.Length >= count)
{
string dtmf = _dtmf.Substring(0, count);
- _dtmf = _dtmf.Remove(count);
+ if (_dtmf.Length == count)
+ _dtmf = string.Empty;
+ else
+ _dtmf = _dtmf.Remove(count);
+ _dtmfWaitCount = 0;
return dtmf;
}
}
+ _dtmfWaitCount = 0;
return string.Empty;
}
+ private void OnDtmfTimeout(PrivateWaitDtmf dtmf)
+ {
+ dtmf.Dispose();
+ _dtmfTimeout.Set();
+ }
+
+ /// <summary>
+ /// Wait on dtmf.
+ /// </summary>
+ /// <param name="count">Number of digits to get</param>
+ /// <remarks>You can also used the Dtmf event if you want to use asynchrounous programming.</remarks>
+ /// <seealso cref="DtmfReceived"/>
+ /// <seealso cref="DefaultTimeout"/>
+ public string GetDtmf(int count)
+ {
+ return GetDtmf(count, _defaultTimeout);
+ }
+
+ /// <summary>
+ /// Play a sound file
+ /// </summary>
+ /// <param name="path">Path to sound file.</param>
+ /// <seealso cref="AllDigits"/>
+ /// <remarks>Prepends <see cref="BaseSoundPath"/> to path.</remarks>
+ public void Play(string path)
+ {
+ Play(path, AllDigits);
+ }
+
+ /// <summary>
+ /// Play a sound file
+ /// </summary>
+ /// <param name="path">Path to sound file.</param>
+ /// <param name="digitsToAbortOn">DTMF digits that can abort speech.</param>
+ /// <remarks>Prepends <see cref="BaseSoundPath"/> to path.</remarks>
public void Play(string path, string digitsToAbortOn)
{
if (_mgr == null)
@@ -144,69 +239,61 @@
_lastAbortDigits = digitsToAbortOn;
}
- _mgr.Send(new PlaybackCmd(_uuid, _baseSoundPath + path));
+ _queue.Add(new PlaybackCmd(_uuid, GetSoundPath(path, false), digitsToAbortOn));
}
- public void Record(string path, bool stop, int limit)
- {
- if (_mgr == null)
- return;
- _mgr.Send(new RecordCmd(_uuid, _baseSoundPath + path, stop, limit));
- }
- public void Record(string path, int limit)
- {
- if (_mgr == null)
- return;
- _mgr.Send(new RecordCmd(_uuid, _baseSoundPath + path, limit));
- }
- public void Sleep(int ms)
+ /// <summary>
+ /// Record a sound file
+ /// </summary>
+ /// <param name="path">Where to store the sound</param>
+ /// <param name="limit">Maximum number of seconds that can be recorded.</param>
+ /// <param name="stop">stop an ongoing recording</param>
+ public void Record(string path, int limit, bool stop)
{
if (_mgr == null)
return;
- _mgr.Send(new SleepCmd(_uuid, ms));
- }
- }
- public class DtmfEventArgs : EventArgs
- {
- private string _dtmf;
- private string _dtmfCopy;
+ _queue.Add(new RecordCmd(_uuid, GetSoundPath(path, true), stop, limit));
+ }
- public DtmfEventArgs(string dtmf)
+ /// <summary>
+ /// Record a sound file
+ /// </summary>
+ /// <param name="path">Where to store the sound</param>
+ /// <param name="limit">Maximum number of seconds that can be recorded.</param>
+ public void Record(string path, int limit)
{
- _dtmf = dtmf;
- _dtmfCopy = (string) _dtmf.Clone();
+ Record(path, limit, false);
}
/// <summary>
- /// You cannot remove digits from the buffer (since it's a copy of the real buffer).
+ /// This method can be used to build paths for different languages and such.
/// </summary>
- /// <seealso cref="RemoveDigits"/>
- public string Dtmf
+ /// <param name="fileName">soundfile</param>
+ /// <param name="isRecording">path is to a file being recorded</param>
+ /// <returns>Path to sound file</returns>
+ protected virtual string GetSoundPath(string fileName, bool isRecording)
{
- get { return _dtmfCopy; }
+ return BaseSoundPath + fileName;
}
/// <summary>
- /// Remove digits from the real buffer.
+ /// Tell script to sleep for a while.
/// </summary>
- /// <param name="count">number of digits to remove.</param>
- public void RemoveDigits(int count)
+ /// <param name="ms">number of milliseconds</param>
+ public void Sleep(int ms)
{
- lock (_dtmf)
- {
- if (count > _dtmf.Length)
- _dtmf = string.Empty;
- else
- _dtmf = _dtmf.Remove(0, count);
- _dtmfCopy = (string)_dtmf.Clone();
- }
+ if (_mgr == null)
+ return;
+
+ _queue.Add(new SleepCmd(_uuid, ms));
}
+
+
}
- public delegate void DtmfHandler(object source, DtmfEventArgs args);
public delegate void IvrInterfaceHandler(IvrInterface app);
-}
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrQueue.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrQueue.cs Fri May 2 07:23:27 2008
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using FreeSwitch.EventSocket.Commands;
+
+namespace FreeSwitch.EventSocket.Ivr
+{
+ internal class IvrQueue
+ {
+ private readonly Queue<CmdBase> _items = new Queue<CmdBase>();
+ private readonly EventManager _mgr;
+ private CmdBase _currentCommand;
+
+ public IvrQueue(EventManager mgr)
+ {
+ if (mgr == null)
+ throw new ArgumentNullException("mgr");
+
+ _mgr = mgr;
+ }
+
+ public bool CommandRunning
+ {
+ get { return _currentCommand != null; }
+ }
+
+ public void Add(CmdBase cmd)
+ {
+ lock (_items)
+ _items.Enqueue(cmd);
+ }
+
+ public void Execute(EventChannelExecute evt)
+ {
+ }
+
+ public void ExecuteComplete(EventChannelExecuteComplete evt)
+ {
+ Console.WriteLine(evt.AppName + "(" + evt.Arguments + ") is done.");
+
+ if (_currentCommand != null && evt.AppName != _currentCommand.Command)
+ {
+ Console.WriteLine("Executed something that is not ours: " + _currentCommand.Command);
+ return;
+ }
+
+ // run next command
+ lock (_items)
+ {
+ _currentCommand = null;
+
+ if (_items.Count > 0)
+ {
+ // check if next cmd is waiting on dtmf, then trigger it to start.
+ if (_items.Peek().Command == "privdtmf")
+ ((PrivateWaitDtmf) _items.Peek()).Trigger();
+
+ SendNextCommand();
+ }
+ }
+ }
+
+ /// <summary>
+ /// a DTMF was pressed. Validate it towards the queue
+ /// </summary>
+ /// <param name="digit"></param>
+ /// <returns>true if it can be processed, false if not.</returns>
+ public bool GotDtmf(char digit)
+ {
+ bool isValid = true;
+
+ lock (_items)
+ {
+ // dequeue all play commands if correct digit is pressed.
+ while (_items.Count > 0)
+ {
+ if (_items.Peek().GetType() == typeof (SetVariable))
+ {
+ Console.WriteLine("Is SetVariable");
+ SetVariable var = (SetVariable) _items.Peek();
+ string digits = string.Empty;
+ digits += digit;
+ if (var.Name == "playback_terminators" )
+ {
+ if (var.Value.Contains(digits))
+ {
+ _items.Dequeue();
+ if (_items.Count > 0 && _items.Peek().GetType() == typeof(PlaybackCmd))
+ _items.Dequeue();
+ }
+ else
+ isValid = false; //digit was not one of the terminators. skip it.
+ }
+ }
+ else if (_items.Peek().GetType() == typeof(PlaybackCmd))
+ {
+ Console.WriteLine("Is PlaybackCmd");
+ PlaybackCmd cmd = (PlaybackCmd)_items.Peek();
+ string digits = string.Empty;
+ digits += digit;
+ if (cmd.DtmfAbort.Contains(digits))
+ _items.Dequeue();
+ else
+ {
+ isValid = false; //digit was not one of the terminators, skip it.
+ break;
+ }
+ }
+ else
+ break;
+ }
+
+ // and dequeue the dtmf command.
+ if (_items.Count > 0 && _items.Peek().GetType() == typeof(PrivateWaitDtmf))
+ ((PrivateWaitDtmf) _items.Dequeue()).Dispose();
+ }
+
+ return isValid;
+ }
+
+ private static void OnCommandReply(CmdBase command, CommandReply reply)
+ {
+ command.ReplyReceived -= OnCommandReply;
+ if (!reply.Success)
+ {
+ Console.WriteLine("Command failed: " + reply.ErrorMessage);
+ }
+ }
+
+ public CmdBase Peek()
+ {
+ lock (_items)
+ {
+ return _items.Peek();
+ }
+ }
+
+ public CmdBase Pop()
+ {
+ lock (_items)
+ {
+ return _items.Dequeue();
+ }
+ }
+
+ private void SendNextCommand()
+ {
+ lock (_items)
+ {
+ if (_currentCommand != null)
+ throw new InvalidOperationException("A command is already running.");
+
+ _currentCommand = _items.Dequeue();
+ }
+
+ _currentCommand.ReplyReceived += OnCommandReply;
+ _mgr.Send(_currentCommand);
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/PrivateWaitDtmf.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/PrivateWaitDtmf.cs Fri May 2 07:23:27 2008
@@ -0,0 +1,70 @@
+using System;
+using System.Threading;
+using FreeSwitch.EventSocket.Commands;
+
+namespace FreeSwitch.EventSocket.Ivr
+{
+ internal delegate void DtmfTimeoutHandler(PrivateWaitDtmf dtmf);
+
+ internal class PrivateWaitDtmf : CmdBase, IDisposable
+ {
+ private Timer _timer;
+ private readonly int _waitTime;
+ private readonly DtmfTimeoutHandler _handler;
+
+ /// <summary>
+ /// DTMF timeouts should be counted AFTER a phrase has been said.
+ /// this small command allows us to start the timer when so.
+ /// </summary>
+ /// <param name="handler">Method that will be signalled when the DTMF command goes on timeout.</param>
+ /// <param name="time">Number of seconds to wait on input.</param>
+ public PrivateWaitDtmf(DtmfTimeoutHandler handler, int time)
+ {
+ if (handler == null)
+ throw new ArgumentNullException("handler");
+ if (time == 0)
+ throw new ArgumentException("time cannot be 0.", "time");
+ if (time < 100)
+ time *= 1000;
+ _waitTime = time;
+ _handler = handler;
+ }
+
+ public override string Command
+ {
+ get { return "privdtmf"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _waitTime.ToString(); }
+ }
+
+ public void Trigger()
+ {
+ _timer = new Timer(OnTimeout, null, _waitTime, Timeout.Infinite);
+ }
+
+ private void OnTimeout(object state)
+ {
+ _timer.Dispose();
+ _timer = null;
+ _handler(this);
+ }
+
+ #region IDisposable Members
+
+ ///<summary>
+ ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ ///</summary>
+ ///<filterpriority>2</filterpriority>
+ public void Dispose()
+ {
+ if (_timer != null)
+ _timer.Dispose();
+ _timer = null;
+ }
+
+ #endregion
+ }
+}
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs Fri May 2 07:23:27 2008
@@ -1,5 +1,7 @@
using System;
+using System.Threading;
using FreeSwitch.EventSocket;
+using FreeSwitch.EventSocket.Commands;
namespace IvrSocket
{
@@ -12,17 +14,13 @@
mgr.EventReceived += IvrManager;
mgr.Subscribe(Event.All);
mgr.Start("localhost");
+ Thread.Sleep(1000);
+ //mgr.Send(new SendEventCmd(new EventMessageWaiting("jonas(a)192.168.0.58", 1, 2)));
Console.ReadLine();
}
private static void IvrManager(EventBase receivedEvent)
{
- Console.WriteLine(receivedEvent.Name);
- if (receivedEvent is ChannelEvent)
- {
- ChannelEvent evt = (ChannelEvent) receivedEvent;
- Console.WriteLine(evt.Name + ": " + evt.UniqueId);
- }
if (receivedEvent is EventChannelAnswer)
{
EventChannelAnswer answer = (EventChannelAnswer)receivedEvent;
Modified: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs
==============================================================================
--- freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs (original)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs Fri May 2 07:23:27 2008
@@ -21,6 +21,10 @@
private void OnIvr(IvrInterface app)
{
_ivr.Play("sv\\system\\record_after_beep.wav", IvrInterface.AllDigits);
+ _ivr.Play("sv\\system\\record_after_beep.wav", IvrInterface.AllDigits);
+ _ivr.Play("sv\\system\\record_after_beep.wav", "2");
+ string dtmf = _ivr.GetDtmf(4);
+ Console.WriteLine("Got DTMF: " + dtmf);
//_ivr.Sleep(5000);
//_ivr.Record("voicemails\\" + Guid.NewGuid() + ".wav", 60);
}
1
0
02 May '08
Author: greenlizard
Date: Thu May 1 20:57:25 2008
New Revision: 8244
Modified:
freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h
freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
Log:
reswig against 8241 and fix bugs with changed number of args to playAndGetDigits (note: exising scripts will need to be fixed to pass ONE less argument - see wiki for new syntax). also, comment out hangup hook handler that was causing seg fault, that needs to be redone. registering hangup hooks inscripts will no longer have any effect.
Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py Thu May 1 20:57:25 2008
@@ -1,5 +1,5 @@
# This file was automatically generated by SWIG (http://www.swig.org)
-# Version 1.3.35
+# Version 1.3.31
#
# Don't modify this file, modify the SWIG interface instead.
# This file is compatible with both classic and new-style classes.
@@ -152,7 +152,7 @@
__setattr__ = lambda self, name, value: _swig_setattr(self, CoreSession, name, value)
__swig_getmethods__ = {}
__getattr__ = lambda self, name: _swig_getattr(self, CoreSession, name)
- def __init__(self, *args, **kwargs): raise AttributeError, "No constructor defined"
+ def __init__(self): raise AttributeError, "No constructor defined"
__repr__ = _swig_repr
__swig_destroy__ = _freeswitch.delete_CoreSession
__del__ = lambda self : None;
@@ -215,8 +215,6 @@
dtmf_callback = _freeswitch.dtmf_callback
S_SWAPPED_IN = _freeswitch.S_SWAPPED_IN
S_SWAPPED_OUT = _freeswitch.S_SWAPPED_OUT
-api_execute = _freeswitch.api_execute
-api_reply_delete = _freeswitch.api_reply_delete
class PySession(CoreSession):
__swig_setmethods__ = {}
for _s in [CoreSession]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp Thu May 1 20:57:25 2008
@@ -55,13 +55,17 @@
char *resultStr;
bool did_swap_in = false;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "check_hangup_hook called\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "check_hangup_hook has been DISABLED, please do not use hangup hooks in python code until further notice!\n");
if (!session) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No valid session\n");
return;
}
+ return;
+
+ /*! NEEDS TO BE FIXED:
+
// The did_swap_in boolean was added to fix the following problem:
// Design flaw - we swap in threadstate based on the assumption that thread state
// is currently _swapped out_ when this hangup hook is called. However, nothing known to
@@ -101,7 +105,7 @@
}
Py_XDECREF(result);
-
+ */
}
switch_status_t PySession::run_dtmf_callback(void *input,
Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h Thu May 1 20:57:25 2008
@@ -21,8 +21,6 @@
void console_log(char *level_str, char *msg);
void console_clean_log(char *msg);
-char *api_execute(char *cmd, char *arg);
-void api_reply_delete(char *reply);
class PySession : public CoreSession {
private:
Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Thu May 1 20:57:25 2008
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org)
- * Version 1.3.35
+ * Version 1.3.31
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -12,7 +12,7 @@
#define SWIG_PYTHON_DIRECTOR_NO_VTABLE
#ifdef __cplusplus
-template<typename T> class SwigValueWrapper {
+template<class T> class SwigValueWrapper {
T *tt;
public:
SwigValueWrapper() : tt(0) { }
@@ -25,10 +25,6 @@
private:
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
};
-
-template <typename T> T SwigValueInit() {
- return T();
-}
#endif
/* -----------------------------------------------------------------------------
@@ -38,14 +34,14 @@
/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-# define SWIGTEMPLATEDISAMBIGUATOR template
-# elif defined(__HP_aCC)
-/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
-/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
-# define SWIGTEMPLATEDISAMBIGUATOR template
+# if defined(__SUNPRO_CC)
+# if (__SUNPRO_CC <= 0x560)
+# define SWIGTEMPLATEDISAMBIGUATOR template
+# else
+# define SWIGTEMPLATEDISAMBIGUATOR
+# endif
# else
-# define SWIGTEMPLATEDISAMBIGUATOR
+# define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif
@@ -128,12 +124,6 @@
# define _CRT_SECURE_NO_DEPRECATE
#endif
-/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
-#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
-# define _SCL_SECURE_NO_DEPRECATE
-#endif
-
-
/* Python.h has to appear first */
#include <Python.h>
@@ -147,7 +137,7 @@
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "4"
+#define SWIG_RUNTIME_VERSION "3"
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
@@ -182,7 +172,6 @@
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
-#define SWIG_CAST_NEW_MEMORY 0x2
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
@@ -323,10 +312,10 @@
extern "C" {
#endif
-typedef void *(*swig_converter_func)(void *, int *);
+typedef void *(*swig_converter_func)(void *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
-/* Structure to store information on one type */
+/* Structure to store inforomation on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
@@ -371,7 +360,7 @@
while ((*f2 == ' ') && (f2 != l2)) ++f2;
if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
}
- return (int)((l1 - f1) - (l2 - f2));
+ return (l1 - f1) - (l2 - f2);
}
/*
@@ -453,8 +442,8 @@
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
- return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
}
/*
@@ -878,7 +867,7 @@
Py_DECREF(old_str);
Py_DECREF(value);
} else {
- PyErr_SetString(PyExc_RuntimeError, mesg);
+ PyErr_Format(PyExc_RuntimeError, mesg);
}
}
@@ -1118,14 +1107,14 @@
/* Unpack the argument tuple */
SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
{
if (!args) {
if (!min && !max) {
return 1;
} else {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
- name, (min == max ? "" : "at least "), (int)min);
+ name, (min == max ? "" : "at least "), min);
return 0;
}
}
@@ -1133,14 +1122,14 @@
PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
return 0;
} else {
- register Py_ssize_t l = PyTuple_GET_SIZE(args);
+ register int l = PyTuple_GET_SIZE(args);
if (l < min) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at least "), (int)min, (int)l);
+ name, (min == max ? "" : "at least "), min, l);
return 0;
} else if (l > max) {
PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
- name, (min == max ? "" : "at most "), (int)max, (int)l);
+ name, (min == max ? "" : "at most "), max, l);
return 0;
} else {
register int i;
@@ -1438,7 +1427,7 @@
{
PySwigObject *sobj = (PySwigObject *) v;
PyObject *next = sobj->next;
- if (sobj->own == SWIG_POINTER_OWN) {
+ if (sobj->own) {
swig_type_info *ty = sobj->ty;
PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
@@ -1456,13 +1445,12 @@
res = ((*meth)(mself, v));
}
Py_XDECREF(res);
- }
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
- else {
+ } else {
const char *name = SWIG_TypePrettyName(ty);
- printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
- }
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+ printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
#endif
+ }
}
Py_XDECREF(next);
PyObject_DEL(v);
@@ -1620,11 +1608,9 @@
(unaryfunc)0, /*nb_float*/
(unaryfunc)PySwigObject_oct, /*nb_oct*/
(unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+#if PY_VERSION_HEX >= 0x02020000
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
+#elif PY_VERSION_HEX >= 0x02000000
0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
#endif
};
@@ -1967,7 +1953,7 @@
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
- if (own == SWIG_POINTER_OWN) {
+ if (own) {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
@@ -1988,8 +1974,6 @@
return SWIG_OK;
} else {
PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
- if (own)
- *own = 0;
while (sobj) {
void *vptr = sobj->ptr;
if (ty) {
@@ -2003,15 +1987,7 @@
if (!tc) {
sobj = (PySwigObject *)sobj->next;
} else {
- if (ptr) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- if (newmemory == SWIG_CAST_NEW_MEMORY) {
- assert(own);
- if (own)
- *own = *own | SWIG_CAST_NEW_MEMORY;
- }
- }
+ if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
break;
}
}
@@ -2021,8 +1997,7 @@
}
}
if (sobj) {
- if (own)
- *own = *own | sobj->own;
+ if (own) *own = sobj->own;
if (flags & SWIG_POINTER_DISOWN) {
sobj->own = 0;
}
@@ -2087,13 +2062,8 @@
}
if (ty) {
swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
- if (tc) {
- int newmemory = 0;
- *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
- assert(!newmemory); /* newmemory handling not yet implemented */
- } else {
- return SWIG_ERROR;
- }
+ if (!tc) return SWIG_ERROR;
+ *ptr = SWIG_TypeCast(tc,vptr);
} else {
*ptr = vptr;
}
@@ -2511,12 +2481,11 @@
#define SWIGTYPE_p_switch_input_args_t swig_types[13]
#define SWIGTYPE_p_switch_input_type_t swig_types[14]
#define SWIGTYPE_p_switch_priority_t swig_types[15]
-#define SWIGTYPE_p_switch_size_t swig_types[16]
-#define SWIGTYPE_p_switch_status_t swig_types[17]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[18]
-#define SWIGTYPE_p_void swig_types[19]
-static swig_type_info *swig_types[21];
-static swig_module_info swig_module = {swig_types, 20, 0, 0, 0, 0};
+#define SWIGTYPE_p_switch_status_t swig_types[16]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[17]
+#define SWIGTYPE_p_void swig_types[18]
+static swig_type_info *swig_types[20];
+static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -2535,7 +2504,7 @@
#define SWIG_name "_freeswitch"
-#define SWIGVERSION 0x010335
+#define SWIGVERSION 0x010331
#define SWIG_VERSION SWIGVERSION
@@ -2563,9 +2532,7 @@
PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
{
- if (initial_ref) {
- Py_XINCREF(_obj);
- }
+ if (initial_ref) Py_XINCREF(_obj);
}
PyObject_ptr & operator=(const PyObject_ptr& item)
@@ -2715,12 +2682,14 @@
#include <limits.h>
-#if !defined(SWIG_NO_LLONG_MAX)
-# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
-# define LLONG_MAX __LONG_LONG_MAX__
-# define LLONG_MIN (-LLONG_MAX - 1LL)
-# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
-# endif
+#ifndef LLONG_MIN
+# define LLONG_MIN LONG_LONG_MIN
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX LONG_LONG_MAX
+#endif
+#ifndef ULLONG_MAX
+# define ULLONG_MAX ULONG_LONG_MAX
#endif
@@ -2944,11 +2913,18 @@
SWIGINTERN int
SWIG_AsVal_bool (PyObject *obj, bool *val)
{
- int r = PyObject_IsTrue(obj);
- if (r == -1)
- return SWIG_ERROR;
- if (val) *val = r ? true : false;
- return SWIG_OK;
+ if (obj == Py_True) {
+ if (val) *val = true;
+ return SWIG_OK;
+ } else if (obj == Py_False) {
+ if (val) *val = false;
+ return SWIG_OK;
+ } else {
+ long v = 0;
+ int res = SWIG_AddCast(SWIG_AsVal_long (obj, val ? &v : 0));
+ if (SWIG_IsOK(res) && val) *val = v ? true : false;
+ return res;
+ }
}
#ifdef __cplusplus
@@ -3131,7 +3107,7 @@
SWIGINTERN PyObject *API_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_API, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -3387,7 +3363,7 @@
SWIGINTERN PyObject *input_callback_state_t_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_input_callback_state, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -3433,7 +3409,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 1); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -3451,10 +3427,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_Stream'.\n"
- " Possible C/C++ prototypes are:\n"
- " Stream()\n"
- " Stream(switch_stream_handle_t *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_Stream'.\n Possible C/C++ prototypes are:\n Stream()\n Stream(switch_stream_handle_t *)\n");
return NULL;
}
@@ -3538,7 +3511,7 @@
SWIGINTERN PyObject *Stream_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_Stream, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -3831,7 +3804,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 2); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -3881,12 +3854,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_Event'.\n"
- " Possible C/C++ prototypes are:\n"
- " Event(char const *,char const *)\n"
- " Event(char const *)\n"
- " Event(switch_event_t *,int)\n"
- " Event(switch_event_t *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_Event'.\n Possible C/C++ prototypes are:\n Event(char const *,char const *)\n Event(char const *)\n Event(switch_event_t *,int)\n Event(switch_event_t *)\n");
return NULL;
}
@@ -3975,7 +3943,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 2); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -4003,10 +3971,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Event_serialize'.\n"
- " Possible C/C++ prototypes are:\n"
- " serialize(Event *,char const *)\n"
- " serialize(Event *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Event_serialize'.\n Possible C/C++ prototypes are:\n serialize(char const *)\n serialize()\n");
return NULL;
}
@@ -4078,7 +4043,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 2); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -4106,10 +4071,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Event_setPriority'.\n"
- " Possible C/C++ prototypes are:\n"
- " setPriority(Event *,switch_priority_t)\n"
- " setPriority(Event *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Event_setPriority'.\n Possible C/C++ prototypes are:\n setPriority(switch_priority_t)\n setPriority()\n");
return NULL;
}
@@ -4330,7 +4292,7 @@
SWIGINTERN PyObject *Event_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_Event, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -4787,7 +4749,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 2); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -4815,10 +4777,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_hangup'.\n"
- " Possible C/C++ prototypes are:\n"
- " hangup(CoreSession *,char *)\n"
- " hangup(CoreSession *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_hangup'.\n Possible C/C++ prototypes are:\n hangup(char *)\n hangup()\n");
return NULL;
}
@@ -5172,7 +5131,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 5); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -5266,12 +5225,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_recordFile'.\n"
- " Possible C/C++ prototypes are:\n"
- " recordFile(CoreSession *,char *,int,int,int)\n"
- " recordFile(CoreSession *,char *,int,int)\n"
- " recordFile(CoreSession *,char *,int)\n"
- " recordFile(CoreSession *,char *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_recordFile'.\n Possible C/C++ prototypes are:\n recordFile(char *,int,int,int)\n recordFile(char *,int,int)\n recordFile(char *,int)\n recordFile(char *)\n");
return NULL;
}
@@ -5422,7 +5376,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 4); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -5470,10 +5424,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_originate'.\n"
- " Possible C/C++ prototypes are:\n"
- " originate(CoreSession *,CoreSession *,char *,int)\n"
- " originate(CoreSession *,CoreSession *,char *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_originate'.\n Possible C/C++ prototypes are:\n originate(CoreSession *,char *,int)\n originate(CoreSession *,char *)\n");
return NULL;
}
@@ -5631,15 +5582,15 @@
SWIGINTERN PyObject *_wrap_CoreSession_getDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
- switch_size_t arg2 ;
+ int arg2 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
int arg5 ;
char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 ;
- int res2 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
int res3 ;
char *buf3 = 0 ;
int alloc3 = 0 ;
@@ -5662,19 +5613,11 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- {
- res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_switch_size_t, 0 | 0);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
- }
- if (!argp2) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
- } else {
- switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp2);
- arg2 = *temp;
- if (SWIG_IsNewObj(res2)) delete temp;
- }
- }
+ ecode2 = SWIG_AsVal_int(obj1, &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'");
@@ -5953,7 +5896,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 3); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -5991,10 +5934,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_streamFile'.\n"
- " Possible C/C++ prototypes are:\n"
- " streamFile(CoreSession *,char *,int)\n"
- " streamFile(CoreSession *,char *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CoreSession_streamFile'.\n Possible C/C++ prototypes are:\n streamFile(char *,int)\n streamFile(char *)\n");
return NULL;
}
@@ -6359,7 +6299,7 @@
SWIGINTERN PyObject *CoreSession_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_CoreSession, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -6544,67 +6484,6 @@
}
-SWIGINTERN PyObject *_wrap_api_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- char *arg1 = (char *) 0 ;
- char *arg2 = (char *) 0 ;
- char *result = 0 ;
- int res1 ;
- char *buf1 = 0 ;
- int alloc1 = 0 ;
- int res2 ;
- char *buf2 = 0 ;
- int alloc2 = 0 ;
- PyObject * obj0 = 0 ;
- PyObject * obj1 = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)"OO:api_execute",&obj0,&obj1)) SWIG_fail;
- res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "api_execute" "', argument " "1"" of type '" "char *""'");
- }
- arg1 = reinterpret_cast< char * >(buf1);
- res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "api_execute" "', argument " "2"" of type '" "char *""'");
- }
- arg2 = reinterpret_cast< char * >(buf2);
- result = (char *)api_execute(arg1,arg2);
- resultobj = SWIG_FromCharPtr((const char *)result);
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
- return resultobj;
-fail:
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_api_reply_delete(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
- PyObject *resultobj = 0;
- char *arg1 = (char *) 0 ;
- int res1 ;
- char *buf1 = 0 ;
- int alloc1 = 0 ;
- PyObject * obj0 = 0 ;
-
- if (!PyArg_ParseTuple(args,(char *)"O:api_reply_delete",&obj0)) SWIG_fail;
- res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "api_reply_delete" "', argument " "1"" of type '" "char *""'");
- }
- arg1 = reinterpret_cast< char * >(buf1);
- api_reply_delete(arg1);
- resultobj = SWIG_Py_Void();
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- return resultobj;
-fail:
- if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_new_PySession__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
PySession *result = 0 ;
@@ -6671,7 +6550,7 @@
int ii;
if (!PyTuple_Check(args)) SWIG_fail;
- argc = (int)PyObject_Length(args);
+ argc = PyObject_Length(args);
for (ii = 0; (ii < argc) && (ii < 1); ii++) {
argv[ii] = PyTuple_GET_ITEM(args,ii);
}
@@ -6697,11 +6576,7 @@
}
fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_PySession'.\n"
- " Possible C/C++ prototypes are:\n"
- " PySession()\n"
- " PySession(char *)\n"
- " PySession(switch_core_session_t *)\n");
+ SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_PySession'.\n Possible C/C++ prototypes are:\n PySession()\n PySession(char *)\n PySession(switch_core_session_t *)\n");
return NULL;
}
@@ -6934,7 +6809,7 @@
SWIGINTERN PyObject *PySession_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *obj;
- if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+ if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
SWIG_TypeNewClientData(SWIGTYPE_p_PySession, SWIG_NewClientData(obj));
return SWIG_Py_Void();
}
@@ -7031,8 +6906,6 @@
{ (char *)"bridge", _wrap_bridge, METH_VARARGS, NULL},
{ (char *)"hanguphook", _wrap_hanguphook, METH_VARARGS, NULL},
{ (char *)"dtmf_callback", _wrap_dtmf_callback, METH_VARARGS, NULL},
- { (char *)"api_execute", _wrap_api_execute, METH_VARARGS, NULL},
- { (char *)"api_reply_delete", _wrap_api_reply_delete, METH_VARARGS, NULL},
{ (char *)"new_PySession", _wrap_new_PySession, METH_VARARGS, NULL},
{ (char *)"delete_PySession", _wrap_delete_PySession, METH_VARARGS, NULL},
{ (char *)"PySession_setDTMFCallback", _wrap_PySession_setDTMFCallback, METH_VARARGS, NULL},
@@ -7049,7 +6922,7 @@
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
-static void *_p_PySessionTo_p_CoreSession(void *x, int *newmemory) {
+static void *_p_PySessionTo_p_CoreSession(void *x) {
return (void *)((CoreSession *) ((PySession *) x));
}
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)0, 0};
@@ -7058,7 +6931,7 @@
static swig_type_info _swigt__p_PySession = {"_p_PySession", "PySession *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_Stream = {"_p_Stream", "Stream *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_input_callback_state = {"_p_input_callback_state", "input_callback_state_t *|input_callback_state *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_input_callback_state = {"_p_input_callback_state", "input_callback_state *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_session_flag_t = {"_p_session_flag_t", "enum session_flag_t *|session_flag_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_swap_state_t = {"_p_swap_state_t", "enum swap_state_t *|swap_state_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_channel_state_t = {"_p_switch_channel_state_t", "switch_channel_state_t *", 0, 0, (void*)0, 0};
@@ -7068,7 +6941,6 @@
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "switch_priority_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_switch_size_t = {"_p_switch_size_t", "switch_size_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -7090,7 +6962,6 @@
&_swigt__p_switch_input_args_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_priority_t,
- &_swigt__p_switch_size_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_void,
@@ -7112,7 +6983,6 @@
static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_priority_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_size_t[] = { {&_swigt__p_switch_size_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -7134,7 +7004,6 @@
_swigc__p_switch_input_args_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_priority_t,
- _swigc__p_switch_size_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_void,
@@ -7206,7 +7075,7 @@
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found, init;
+ int found;
clientdata = clientdata;
@@ -7216,9 +7085,6 @@
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
- init = 1;
- } else {
- init = 0;
}
/* Try and load any already created modules */
@@ -7247,12 +7113,6 @@
module_head->next = &swig_module;
}
- /* When multiple interpeters are used, a module could have already been initialized in
- a different interpreter, but not yet have a pointer in this interpreter.
- In this case, we do not want to continue adding types... everything should be
- set up already */
- if (init == 0) return;
-
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
1
0
Author: brian
Date: Thu May 1 20:24:09 2008
New Revision: 8243
Modified:
freeswitch/trunk/scripts/lua/helloworld.lua
Log:
elaborate
Modified: freeswitch/trunk/scripts/lua/helloworld.lua
==============================================================================
--- freeswitch/trunk/scripts/lua/helloworld.lua (original)
+++ freeswitch/trunk/scripts/lua/helloworld.lua Thu May 1 20:24:09 2008
@@ -1 +1,4 @@
-session:answer(); session:streamFile("blah.wav"); session:hangup();
+-- Simple answer and playback lua example
+session:answer();
+session:streamFile("blah.wav");
+session:hangup();
1
0
Author: greenlizard
Date: Thu May 1 19:39:53 2008
New Revision: 8242
Added:
freeswitch/trunk/scripts/lua/helloworld.lua
Log:
hello world
Added: freeswitch/trunk/scripts/lua/helloworld.lua
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/lua/helloworld.lua Thu May 1 19:39:53 2008
@@ -0,0 +1 @@
+session:answer(); session:streamFile("blah.wav"); session:hangup();
1
0
01 May '08
Author: anthm
Date: Thu May 1 18:56:14 2008
New Revision: 8241
Added:
freeswitch/trunk/src/mod/languages/mod_perl/hack.diff
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.c
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h
Modified:
freeswitch/trunk/src/mod/languages/mod_perl/Makefile
freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm
freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
Log:
adding callback stuff, still gotta test it
Modified: freeswitch/trunk/src/mod/languages/mod_perl/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/Makefile (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/Makefile Thu May 1 18:56:14 2008
@@ -15,6 +15,10 @@
mod_perl_wrap.cpp:
swig -static -shadow -perl5 -c++ -DMULTIPLICITY -I../../../../src/include -o mod_perl_wrap.cpp freeswitch.i
+ echo "#include \"mod_perl_extra.c\"" >> mod_perl_wrap.cpp
+ patch -s -p0 -i hack.diff
+
+
freeswitch.$(DYNAMIC_LIB_EXTEN): $(LOCAL_OBJS) $(LOCAL_LIBADD)
$(LINK) $(SOLINK) -o freeswitch.$(DYNAMIC_LIB_EXTEN) $(LOCAL_OBJS) $(LOCAL_LIBADD) $(LDFLAGS)
Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm Thu May 1 18:56:14 2008
@@ -333,6 +333,16 @@
*end_allow_threads = *freeswitchc::Session_end_allow_threads;
*check_hangup_hook = *freeswitchc::Session_check_hangup_hook;
*run_dtmf_callback = *freeswitchc::Session_run_dtmf_callback;
+*setInputCallback = *freeswitchc::Session_setInputCallback;
+*setHangupHook = *freeswitchc::Session_setHangupHook;
+*ready = *freeswitchc::Session_ready;
+*swig_cb_function_get = *freeswitchc::Session_cb_function_get;
+*swig_cb_function_set = *freeswitchc::Session_cb_function_set;
+*swig_cb_arg_get = *freeswitchc::Session_cb_arg_get;
+*swig_cb_arg_set = *freeswitchc::Session_cb_arg_set;
+*swig_hangup_func_str_get = *freeswitchc::Session_hangup_func_str_get;
+*swig_hangup_func_str_set = *freeswitchc::Session_hangup_func_str_set;
+*setPERL = *freeswitchc::Session_setPERL;
sub DISOWN {
my $self = shift;
my $ptr = tied(%$self);
Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp Thu May 1 18:56:14 2008
@@ -1,85 +1,206 @@
+#include <switch.h>
#include "freeswitch_perl.h"
+#include "mod_perl_extra.h"
+
+static STRLEN n_a;
Session::Session() : CoreSession()
{
-
+ cb_function = cb_arg = hangup_func_str = NULL;
+ hh = mark = 0;
}
Session::Session(char *uuid) : CoreSession(uuid)
{
-
+ cb_function = cb_arg = hangup_func_str = NULL;
+ hh = mark = 0;
}
Session::Session(switch_core_session_t *new_session) : CoreSession(new_session)
{
-
+ cb_function = cb_arg = hangup_func_str = NULL;
+ hh = mark = 0;
}
-
-Session::~Session()
+static switch_status_t perl_hanguphook(switch_core_session_t *session_hungup);
+Session::~Session()
{
-
+ switch_safe_free(cb_function);
+ switch_safe_free(cb_arg);
+ switch_safe_free(hangup_func_str);
+ switch_core_event_hook_remove_state_change(session, perl_hanguphook);
}
-
bool Session::begin_allow_threads()
{
+ do_hangup_hook();
return true;
}
bool Session::end_allow_threads()
{
+ do_hangup_hook();
return true;
}
+void Session::setPERL(PerlInterpreter *pi)
+{
+ my_perl = pi;
+}
+
+PerlInterpreter *Session::getPERL()
+{
+ if (!my_perl) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh!\n");
+ }
+ return my_perl;
+}
+
+
+bool Session::ready() {
+ bool r;
+
+ sanity_check(false);
+ r = switch_channel_ready(channel) != 0;
+ do_hangup_hook();
+
+ return r;
+}
+
void Session::check_hangup_hook()
{
+ if (hangup_func_str && (hook_state == CS_HANGUP || hook_state == CS_RING)) {
+ hh++;
+ }
}
-switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t itype)
+void Session::do_hangup_hook()
{
- return SWITCH_STATUS_FALSE;
+ if (hh && !mark) {
+ const char *err = NULL;
+ mark++;
+ char *code;
+ if (!getPERL()) {
+ return;
+ }
+
+ code = switch_mprintf("%s(%s)", hangup_func_str, hook_state == CS_HANGUP ? "hangup" : "transfer");
+ Perl_eval_pv(my_perl, code, TRUE);
+ free(code);
+ }
}
+static switch_status_t perl_hanguphook(switch_core_session_t *session_hungup)
+{
+ switch_channel_t *channel = switch_core_session_get_channel(session_hungup);
+ CoreSession *coresession = NULL;
+ switch_channel_state_t state = switch_channel_get_state(channel);
-#if 0
-int Session::answer() {}
-int Session::preAnswer() {}
-void Session::hangup(char *cause) {}
-void Session::setVariable(char *var, char *val) {}
-const char *Session::getVariable(char *var) {}
-int Session::recordFile(char *file_name, int max_len, int silence_threshold, int silence_secs) {}
-void Session::setCallerData(char *var, char *val) {}
-int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) {}
-void Session::setDTMFCallback(void *cbfunc, char *funcargs) {}
-int Session::speak(char *text) {}
-void Session::set_tts_parms(char *tts_name, char *voice_name) {}
-int Session::collectDigits(int timeout) {}
-int Session::getDigits(char *dtmf_buf,
- switch_size_t buflen,
- switch_size_t maxdigits,
- char *terminators,
- char *terminator,
- int timeout) {}
-
-int Session::transfer(char *extensions, char *dialplan, char *context) {}
-int Session::playAndGetDigits(int min_digits,
- int max_digits,
- int max_tries,
- int timeout,
- char *terminators,
- char *audio_files,
- char *bad_input_audio_files,
- char *dtmf_buf,
- char *digits_regex) {}
-
-int Session::streamFile(char *file, int starting_sample_count) {}
-int Session::flushEvents() {}
-int Session::flushDigits() {}
-int Session::setAutoHangup(bool val) {}
-void Session::setHangupHook(void *hangup_func) {}
-bool Session::ready() {}
-void Session::execute(char *app, char *data) {}
-char* Session::get_uuid() {}
-const switch_input_args_t& Session::get_cb_args() {}
+ if ((coresession = (CoreSession *) switch_channel_get_private(channel, "CoreSession"))) {
+ if (coresession->hook_state != state) {
+ coresession->hook_state = state;
+ coresession->check_hangup_hook();
+ }
+ }
-#endif
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+void Session::setHangupHook(char *func) {
+
+ sanity_check_noreturn;
+
+ switch_safe_free(hangup_func_str);
+
+ if (func) {
+ hangup_func_str = strdup(func);
+ switch_channel_set_private(channel, "CoreSession", this);
+ hook_state = switch_channel_get_state(channel);
+ switch_core_event_hook_add_state_change(session, perl_hanguphook);
+ }
+}
+
+void Session::setInputCallback(char *cbfunc, char *funcargs) {
+
+ sanity_check_noreturn;
+
+ switch_safe_free(cb_function);
+ if (cbfunc) {
+ cb_function = strdup(cbfunc);
+ }
+
+ switch_safe_free(cb_arg);
+ if (funcargs) {
+ cb_arg = strdup(funcargs);
+ }
+
+ args.buf = this;
+ switch_channel_set_private(channel, "CoreSession", this);
+
+ args.input_callback = dtmf_callback;
+ ap = &args;
+}
+
+switch_status_t Session::run_dtmf_callback(void *input, switch_input_type_t itype)
+{
+ const char *ret;
+
+ if (!getPERL()) {
+ return SWITCH_STATUS_FALSE;;
+ }
+
+ switch (itype) {
+ case SWITCH_INPUT_TYPE_DTMF:
+ {
+ switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
+ char str[32] = "";
+ int arg_count = 2;
+ HV *hash;
+ SV *this_sv;
+ char *code;
+
+ if (!(hash = get_hv("__dtmf", TRUE))) {
+ abort();
+ }
+
+ str[0] = dtmf->digit;
+ this_sv = newSV(strlen(str)+1);
+ sv_setpv(this_sv, str);
+ hv_store(hash, "digit", 5, this_sv, 0);
+
+ switch_snprintf(str, sizeof(str), "%d", dtmf->duration);
+ this_sv = newSV(strlen(str)+1);
+ sv_setpv(this_sv, str);
+ hv_store(hash, "duration", 8, this_sv, 0);
+
+ if (cb_arg) {
+ //this_sv = get_sv(cb_arg, TRUE); DOH!
+ }
+
+ code = switch_mprintf("%s('dtmf', \\%__dtmf, %s);", cb_function, switch_str_nil(cb_arg));
+ Perl_eval_pv(my_perl, code, TRUE);
+ free(code);
+
+ return process_callback_result(SvPV(get_sv(cb_function, FALSE), n_a));
+ }
+ break;
+ case SWITCH_INPUT_TYPE_EVENT:
+ {
+ switch_event_t *event = (switch_event_t *) input;
+ int arg_count = 2;
+ char *code;
+
+ mod_perl_conjure_event(my_perl, event, "__Input_Event__");
+
+ code = switch_mprintf("%s('event', $__Input_Event__, %s);", cb_function, switch_str_nil(cb_arg));
+ Perl_eval_pv(my_perl, code, TRUE);
+ free(code);
+
+
+ return process_callback_result((char *)ret);
+ }
+ break;
+ }
+
+ return SWITCH_STATUS_SUCCESS;
+}
Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h Thu May 1 18:56:14 2008
@@ -1,22 +1,48 @@
-#ifndef FREESWITCH_PYTHON_H
-#define FREESWITCH_PYTHON_H
+#ifndef FREESWITCH_LUA_H
+#define FREESWITCH_LUA_H
-#include <switch_cpp.h>
+extern "C" {
+#ifdef __ICC
+#pragma warning (disable:1419)
+#endif
+#ifdef _MSC_VER
+#include <perlibs.h>
+#pragma comment(lib, PERL_LIB)
+#endif
+
+#include <EXTERN.h>
+#include <perl.h>
+#include <switch.h>
+}
+#include <switch_cpp.h>
class Session : public CoreSession {
private:
+ virtual void do_hangup_hook();
+ PerlInterpreter *getPERL();
+ PerlInterpreter *my_perl;
+ int hh;
+ int mark;
public:
Session();
Session(char *uuid);
Session(switch_core_session_t *session);
~Session();
-
+
virtual bool begin_allow_threads();
virtual bool end_allow_threads();
virtual void check_hangup_hook();
- virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
+ virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
+ void setInputCallback(char *cbfunc, char *funcargs);
+ void setHangupHook(char *func);
+ bool ready();
+
+ char *cb_function;
+ char *cb_arg;
+ char *hangup_func_str;
+ void setPERL(PerlInterpreter *pi);
};
#endif
Added: freeswitch/trunk/src/mod/languages/mod_perl/hack.diff
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/languages/mod_perl/hack.diff Thu May 1 18:56:14 2008
@@ -0,0 +1,30 @@
+--- mod_perl_wrap.cpp 2008-05-01 18:05:28.000000000 -0400
++++ old.cpp 2008-05-01 18:05:51.000000000 -0400
+
+@@ -6293,7 +6293,7 @@
+ if ((items < 0) || (items > 0)) {
+ SWIG_croak("Usage: new_Session();");
+ }
+- result = (Session *)new Session();
++ result = (Session *)new Session(); result->setPERL(my_perl);
+ ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
+ XSRETURN(argvi);
+ fail:
+@@ -6320,7 +6320,7 @@
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'");
+ }
+ arg1 = reinterpret_cast< char * >(buf1);
+- result = (Session *)new Session(arg1);
++ result = (Session *)new Session(arg1); result->setPERL(my_perl);
+ ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
+ if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
+ XSRETURN(argvi);
+@@ -6348,7 +6348,7 @@
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "switch_core_session_t *""'");
+ }
+ arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
+- result = (Session *)new Session(arg1);
++ result = (Session *)new Session(arg1); result->setPERL(my_perl);
+ ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
+
+ XSRETURN(argvi);
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c Thu May 1 18:56:14 2008
@@ -56,19 +56,87 @@
char *xml_handler;
} globals;
-static int Perl_safe_eval(PerlInterpreter *my_perl, const char *string, int tf)
+
+
+static int Perl_safe_eval(PerlInterpreter *my_perl, const char *string)
{
char *err = NULL;
Perl_eval_pv(my_perl, string, FALSE);
if ((err = SvPV(get_sv("@", TRUE), n_a)) && !switch_strlen_zero(err)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "[%s]\n%s\n", string, err);
return -1;
}
return 0;
}
+
+
+static int perl_parse_and_execute(PerlInterpreter *my_perl, char *input_code, char *setup_code)
+{
+ int error = 0;
+
+ if (switch_strlen_zero(input_code)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No code to execute!\n");
+ return -1;
+ }
+
+ if (setup_code) {
+ error = Perl_safe_eval(my_perl, setup_code);
+ if (error) {
+ return error;
+ }
+ }
+
+ if (*input_code == '~') {
+ char *buff = input_code + 1;
+ error = Perl_safe_eval(my_perl, buff);
+ } else {
+ char *args = strchr(input_code, ' ');
+ if (args) {
+ char *code = NULL;
+ int x, argc;
+ char *argv[128] = { 0 };
+ *args++ = '\0';
+
+ if ((argc = switch_separate_string(args, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+ switch_stream_handle_t stream = { 0 };
+ SWITCH_STANDARD_STREAM(stream);
+
+ stream.write_function(&stream, " @ARGV = ( ");
+ for (x = 0; x < argc; x++) {
+ stream.write_function(&stream, "'%s'%s", argv[x], x == argc-1 ? "" : ", ");
+ }
+ stream.write_function(&stream, " );");
+ code = stream.data;
+ } else {
+ code = switch_mprintf("ARGV = ();");
+ }
+
+ if (code) {
+ error = Perl_safe_eval(my_perl, code);
+ switch_safe_free(code);
+ }
+ }
+ if (!error) {
+ char *file = input_code;
+
+ if (!switch_is_file_path(file)) {
+ file = switch_mprintf("require '%s/%s';\n", SWITCH_GLOBAL_dirs.script_dir, file);
+ switch_assert(file);
+ } else {
+ file = switch_mprintf("require '%s';\n", file);
+ switch_assert(file);
+ }
+ error = Perl_safe_eval(my_perl, file);
+ switch_safe_free(file);
+ }
+ }
+
+ return error;
+}
+
static void destroy_perl(PerlInterpreter ** to_destroy)
{
perl_destruct(*to_destroy);
@@ -83,6 +151,7 @@
return my_perl;
}
+#if 0
static perl_parse_and_execute (PerlInterpreter *my_perl, char *input_code, char *setup_code)
{
int error = 0;
@@ -90,8 +159,8 @@
if (*input_code == '~') {
char *buff = input_code + 1;
perl_parse(my_perl, xs_init, 3, embedding, NULL);
- if (setup_code) Perl_safe_eval(my_perl, setup_code, FALSE);
- Perl_safe_eval(my_perl, buff, TRUE);
+ if (setup_code) Perl_safe_eval(my_perl, setup_code);
+ Perl_safe_eval(my_perl, buff);
} else {
int argc = 0;
char *argv[128] = { 0 };
@@ -102,7 +171,7 @@
argc += switch_separate_string(input_code, ' ', &argv[1], (sizeof(argv) / sizeof(argv[0])) - 1);
if (!perl_parse(my_perl, xs_init, argc, argv, (char **)NULL)) {
if (setup_code) {
- if (!Perl_safe_eval(my_perl, setup_code, FALSE)) {
+ if (!Perl_safe_eval(my_perl, setup_code)) {
perl_run(my_perl);
}
}
@@ -115,13 +184,17 @@
}
}
+#endif
static void perl_function(switch_core_session_t *session, char *data)
{
char *uuid = switch_core_session_get_uuid(session);
PerlInterpreter *my_perl = clone_perl();
-
char code[1024];
+
+ perl_parse(my_perl, xs_init, 3, embedding, NULL);
+ Perl_safe_eval(my_perl, code);
+
switch_snprintf(code, sizeof(code),
"use lib '%s/perl';\n"
"use freeswitch;\n"
@@ -133,15 +206,14 @@
uuid);
perl_parse_and_execute(my_perl, data, code);
- Perl_safe_eval(my_perl, "undef $session;", FALSE);
- Perl_safe_eval(my_perl, "undef (*);", FALSE);
+ Perl_safe_eval(my_perl, "undef $session;");
+ Perl_safe_eval(my_perl, "undef (*);");
destroy_perl(&my_perl);
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_perl_shutdown)
{
if (globals.my_perl) {
- perl_destruct(globals.my_perl);
perl_free(globals.my_perl);
globals.my_perl = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Unallocated perl interpreter.\n");
@@ -149,28 +221,71 @@
return SWITCH_STATUS_SUCCESS;
}
+struct perl_o {
+ switch_stream_handle_t *stream;
+ switch_core_session_t *session;
+ char *cmd;
+ int d;
+};
+
static void *SWITCH_THREAD_FUNC perl_thread_run(switch_thread_t *thread, void *obj)
{
- char *input_code = (char *) obj;
PerlInterpreter *my_perl = clone_perl();
char code[1024];
+ SV *sv = NULL;
+ char *uuid = NULL;
+ struct perl_o *po = (struct perl_o *) obj;
+ char *cmd = po->cmd;
+ switch_stream_handle_t *stream = po->stream;
+ switch_core_session_t *session = po->session;
+ if (session) {
+ uuid = switch_core_session_get_uuid(session);
+ }
+
switch_snprintf(code, sizeof(code),
- "use lib '%s/perl';\n"
- "use freeswitch;\n"
- ,
- SWITCH_GLOBAL_dirs.base_dir
- );
+ "use lib '%s/perl';\n"
+ "use freeswitch;\n"
+ "$SWITCH_ENV{UUID} = \"%s\";\n"
+ ,
+
+ SWITCH_GLOBAL_dirs.base_dir,
+ switch_str_nil(uuid)
+ );
+
+ perl_parse(my_perl, xs_init, 3, embedding, NULL);
+ Perl_safe_eval(my_perl, code);
- perl_parse_and_execute(my_perl, input_code, code);
+ if (uuid) {
+ switch_snprintf(code, sizeof(code), "$session = new freeswitch::Session(\"%s\")", uuid);
+ Perl_safe_eval(my_perl, code);
+ }
+
+ if (cmd) {
+ if (stream) {
+ mod_perl_conjure_stream(my_perl, stream, "stream");
+ if (stream->event) {
+ mod_perl_conjure_event(my_perl, stream->event, "env");
+ }
+ }
+ //Perl_safe_eval(my_perl, cmd);
+ perl_parse_and_execute(my_perl, cmd, NULL);
+ }
- if (input_code) {
- free(input_code);
+ if (uuid) {
+ switch_snprintf(code, sizeof(code), "undef $session;", uuid);
+ Perl_safe_eval(my_perl, code);
}
- Perl_safe_eval(my_perl, "undef(*);", FALSE);
+ Perl_safe_eval(my_perl, "undef(*);");
destroy_perl(&my_perl);
+ switch_safe_free(cmd);
+
+ if (po->d) {
+ free(po);
+ }
+
return NULL;
}
@@ -178,11 +293,17 @@
{
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
+ struct perl_o *po;
+ po = malloc(sizeof(*po));
+ memset(po, 0, sizeof(*po));
+ po->cmd = strdup(text);
+ po->d = 1;
+
switch_threadattr_create(&thd_attr, globals.pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, perl_thread_run, strdup(text), globals.pool);
+ switch_thread_create(&thread, thd_attr, perl_thread_run, po, globals.pool);
return 0;
}
@@ -195,51 +316,11 @@
SWITCH_STANDARD_API(perl_api_function) {
- PerlInterpreter *my_perl = clone_perl();
- char code[1024];
- SV *sv = NULL;
- char *uuid = NULL;
-
- if (session) {
- uuid = switch_core_session_get_uuid(session);
- }
-
- switch_snprintf(code, sizeof(code),
- "use lib '%s/perl';\n"
- "use freeswitch;\n"
- "$SWITCH_ENV{UUID} = \"%s\";\n"
- "use IO::String;\n"
- "$handle = IO::String->new($__OUT);\n"
- "select($handle);"
- ,
-
- SWITCH_GLOBAL_dirs.base_dir,
- switch_str_nil(uuid)
- );
-
- perl_parse(my_perl, xs_init, 3, embedding, NULL);
- Perl_safe_eval(my_perl, code, FALSE);
-
- if (uuid) {
- switch_snprintf(code, sizeof(code), "$session = new freeswitch::Session(\"%s\")", uuid);
- Perl_safe_eval(my_perl, code, FALSE);
- }
-
- if (cmd) {
- Perl_safe_eval(my_perl, cmd, FALSE);
- }
-
- stream->write_function(stream, "%s", switch_str_nil(SvPV(get_sv("__OUT", FALSE), n_a)));
-
- if (uuid) {
- switch_snprintf(code, sizeof(code), "undef $session;", uuid);
- Perl_safe_eval(my_perl, code, FALSE);
- }
-
- Perl_safe_eval(my_perl, "undef(*);", FALSE);
- destroy_perl(&my_perl);
-
- return SWITCH_STATUS_SUCCESS;
+ struct perl_o po = { 0 };
+ po.cmd = strdup(cmd);
+ po.stream = stream;
+ po.session = session;
+ perl_thread_run(NULL, &po);
}
static switch_xml_t perl_fetch(const char *section,
@@ -326,7 +407,7 @@
,
SWITCH_GLOBAL_dirs.base_dir
);
- Perl_safe_eval(my_perl, code, FALSE);
+ Perl_safe_eval(my_perl, code);
perl_run(my_perl);
str = SvPV(get_sv("XML_STRING", FALSE), n_a);
Added: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.c
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.c Thu May 1 18:56:14 2008
@@ -0,0 +1,27 @@
+SWITCH_BEGIN_EXTERN_C
+
+
+void mod_perl_conjure_event(PerlInterpreter *my_perl, switch_event_t *event, const char *name)
+{
+ Event *result = 0 ;
+ SV *sv;
+ PERL_SET_CONTEXT(my_perl);
+ sv = sv_2mortal(get_sv(name, TRUE));
+ result = (Event *)new Event(event);
+ SWIG_Perl_MakePtr(sv, result, SWIGTYPE_p_Event, SWIG_OWNER | SWIG_SHADOW);
+}
+
+
+void mod_perl_conjure_stream(PerlInterpreter *my_perl, switch_stream_handle_t *stream, const char *name)
+{
+ Stream *result = 0 ;
+ SV *sv;
+ PERL_SET_CONTEXT(my_perl);
+ sv = sv_2mortal(get_sv(name, TRUE));
+ result = (Stream *)new Stream(stream);
+ SWIG_Perl_MakePtr(sv, result, SWIGTYPE_p_Stream, SWIG_OWNER | SWIG_SHADOW);
+}
+
+
+
+SWITCH_END_EXTERN_C
Added: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h
==============================================================================
--- (empty file)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h Thu May 1 18:56:14 2008
@@ -0,0 +1,9 @@
+#ifndef MOD_PERL_EXTRA
+#define MOD_PERL_EXTRA
+SWITCH_BEGIN_EXTERN_C
+
+void mod_perl_conjure_event(PerlInterpreter *my_perl, switch_event_t *event, const char *name);
+void mod_perl_conjure_stream(PerlInterpreter *my_perl, switch_stream_handle_t *stream, const char *name);
+
+SWITCH_END_EXTERN_C
+#endif
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Thu May 1 18:56:14 2008
@@ -1449,23 +1449,25 @@
#define SWIGTYPE_p_API swig_types[0]
#define SWIGTYPE_p_CoreSession swig_types[1]
#define SWIGTYPE_p_Event swig_types[2]
-#define SWIGTYPE_p_Session swig_types[3]
-#define SWIGTYPE_p_Stream swig_types[4]
-#define SWIGTYPE_p_char swig_types[5]
-#define SWIGTYPE_p_input_callback_state swig_types[6]
-#define SWIGTYPE_p_session_flag_t swig_types[7]
-#define SWIGTYPE_p_switch_channel_state_t swig_types[8]
-#define SWIGTYPE_p_switch_channel_t swig_types[9]
-#define SWIGTYPE_p_switch_core_session_t swig_types[10]
-#define SWIGTYPE_p_switch_event_t swig_types[11]
-#define SWIGTYPE_p_switch_input_args_t swig_types[12]
-#define SWIGTYPE_p_switch_input_type_t swig_types[13]
-#define SWIGTYPE_p_switch_priority_t swig_types[14]
-#define SWIGTYPE_p_switch_status_t swig_types[15]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[16]
-#define SWIGTYPE_p_void swig_types[17]
-static swig_type_info *swig_types[19];
-static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
+#define SWIGTYPE_p_PerlInterpreter swig_types[3]
+#define SWIGTYPE_p_Session swig_types[4]
+#define SWIGTYPE_p_Stream swig_types[5]
+#define SWIGTYPE_p_char swig_types[6]
+#define SWIGTYPE_p_input_callback_state swig_types[7]
+#define SWIGTYPE_p_session_flag_t swig_types[8]
+#define SWIGTYPE_p_switch_channel_state_t swig_types[9]
+#define SWIGTYPE_p_switch_channel_t swig_types[10]
+#define SWIGTYPE_p_switch_core_session_t swig_types[11]
+#define SWIGTYPE_p_switch_event_t swig_types[12]
+#define SWIGTYPE_p_switch_input_args_t swig_types[13]
+#define SWIGTYPE_p_switch_input_type_t swig_types[14]
+#define SWIGTYPE_p_switch_priority_t swig_types[15]
+#define SWIGTYPE_p_switch_size_t swig_types[16]
+#define SWIGTYPE_p_switch_status_t swig_types[17]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[18]
+#define SWIGTYPE_p_void swig_types[19]
+static swig_type_info *swig_types[21];
+static swig_module_info swig_module = {swig_types, 20, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -5222,15 +5224,15 @@
XS(_wrap_CoreSession_getDigits) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
- int arg2 ;
+ switch_size_t arg2 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
int arg5 ;
char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- int val2 ;
- int ecode2 = 0 ;
+ void *argp2 ;
+ int res2 = 0 ;
int res3 ;
char *buf3 = 0 ;
int alloc3 = 0 ;
@@ -5250,11 +5252,17 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
- if (!SWIG_IsOK(ecode2)) {
- SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "int""'");
- }
- arg2 = static_cast< int >(val2);
+ {
+ res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_switch_size_t, 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
+ }
+ if (!argp2) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
+ } else {
+ arg2 = *(reinterpret_cast< switch_size_t * >(argp2));
+ }
+ }
res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'");
@@ -5273,14 +5281,12 @@
result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
-
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
XSRETURN(argvi);
fail:
-
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
@@ -6288,7 +6294,7 @@
if ((items < 0) || (items > 0)) {
SWIG_croak("Usage: new_Session();");
}
- result = (Session *)new Session();
+ result = (Session *)new Session(); result->setPERL(my_perl);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
XSRETURN(argvi);
fail:
@@ -6315,7 +6321,7 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "char *""'");
}
arg1 = reinterpret_cast< char * >(buf1);
- result = (Session *)new Session(arg1);
+ result = (Session *)new Session(arg1); result->setPERL(my_perl);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
XSRETURN(argvi);
@@ -6343,7 +6349,7 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Session" "', argument " "1"" of type '" "switch_core_session_t *""'");
}
arg1 = reinterpret_cast< switch_core_session_t * >(argp1);
- result = (Session *)new Session(arg1);
+ result = (Session *)new Session(arg1); result->setPERL(my_perl);
ST(argvi) = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Session, SWIG_OWNER | SWIG_SHADOW); argvi++ ;
XSRETURN(argvi);
@@ -6586,6 +6592,374 @@
}
+XS(_wrap_Session_setInputCallback) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 3) || (items > 3)) {
+ SWIG_croak("Usage: Session_setInputCallback(self,cbfunc,funcargs);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_setInputCallback" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_setInputCallback" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Session_setInputCallback" "', argument " "3"" of type '" "char *""'");
+ }
+ arg3 = reinterpret_cast< char * >(buf3);
+ (arg1)->setInputCallback(arg2,arg3);
+
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ XSRETURN(argvi);
+ fail:
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_setHangupHook) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: Session_setHangupHook(self,func);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_setHangupHook" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_setHangupHook" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ (arg1)->setHangupHook(arg2);
+
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ XSRETURN(argvi);
+ fail:
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_ready) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 1) || (items > 1)) {
+ SWIG_croak("Usage: Session_ready(self);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_ready" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ result = (bool)(arg1)->ready();
+ ST(argvi) = SWIG_From_bool SWIG_PERL_CALL_ARGS_1(static_cast< bool >(result)); argvi++ ;
+
+ XSRETURN(argvi);
+ fail:
+
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_cb_function_set) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: Session_cb_function_set(self,cb_function);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_cb_function_set" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_cb_function_set" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ if (arg1->cb_function) delete[] arg1->cb_function;
+ if (arg2) {
+ size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
+ arg1->cb_function = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
+ } else {
+ arg1->cb_function = 0;
+ }
+
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ XSRETURN(argvi);
+ fail:
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_cb_function_get) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 1) || (items > 1)) {
+ SWIG_croak("Usage: Session_cb_function_get(self);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_cb_function_get" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ result = (char *) ((arg1)->cb_function);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
+ XSRETURN(argvi);
+ fail:
+
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_cb_arg_set) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: Session_cb_arg_set(self,cb_arg);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_cb_arg_set" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_cb_arg_set" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ if (arg1->cb_arg) delete[] arg1->cb_arg;
+ if (arg2) {
+ size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
+ arg1->cb_arg = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
+ } else {
+ arg1->cb_arg = 0;
+ }
+
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ XSRETURN(argvi);
+ fail:
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_cb_arg_get) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 1) || (items > 1)) {
+ SWIG_croak("Usage: Session_cb_arg_get(self);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_cb_arg_get" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ result = (char *) ((arg1)->cb_arg);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
+ XSRETURN(argvi);
+ fail:
+
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_hangup_func_str_set) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *arg2 = (char *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: Session_hangup_func_str_set(self,hangup_func_str);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_hangup_func_str_set" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_hangup_func_str_set" "', argument " "2"" of type '" "char *""'");
+ }
+ arg2 = reinterpret_cast< char * >(buf2);
+ if (arg1->hangup_func_str) delete[] arg1->hangup_func_str;
+ if (arg2) {
+ size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
+ arg1->hangup_func_str = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
+ } else {
+ arg1->hangup_func_str = 0;
+ }
+
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ XSRETURN(argvi);
+ fail:
+
+ if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_hangup_func_str_get) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ char *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 1) || (items > 1)) {
+ SWIG_croak("Usage: Session_hangup_func_str_get(self);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_hangup_func_str_get" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ result = (char *) ((arg1)->hangup_func_str);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
+ XSRETURN(argvi);
+ fail:
+
+ SWIG_croak_null();
+ }
+}
+
+
+XS(_wrap_Session_setPERL) {
+ {
+ Session *arg1 = (Session *) 0 ;
+ PerlInterpreter *arg2 = (PerlInterpreter *) 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ void *argp2 = 0 ;
+ int res2 = 0 ;
+ int argvi = 0;
+ dXSARGS;
+
+ if ((items < 2) || (items > 2)) {
+ SWIG_croak("Usage: Session_setPERL(self,pi);");
+ }
+ res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Session, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_setPERL" "', argument " "1"" of type '" "Session *""'");
+ }
+ arg1 = reinterpret_cast< Session * >(argp1);
+ res2 = SWIG_ConvertPtr(ST(1), &argp2,SWIGTYPE_p_PerlInterpreter, 0 | 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Session_setPERL" "', argument " "2"" of type '" "PerlInterpreter *""'");
+ }
+ arg2 = reinterpret_cast< PerlInterpreter * >(argp2);
+ (arg1)->setPERL(arg2);
+
+
+
+ XSRETURN(argvi);
+ fail:
+
+
+ SWIG_croak_null();
+ }
+}
+
+
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
@@ -6595,6 +6969,7 @@
static swig_type_info _swigt__p_API = {"_p_API", "API *", 0, 0, (void*)"freeswitch::API", 0};
static swig_type_info _swigt__p_CoreSession = {"_p_CoreSession", "CoreSession *", 0, 0, (void*)"freeswitch::CoreSession", 0};
static swig_type_info _swigt__p_Event = {"_p_Event", "Event *", 0, 0, (void*)"freeswitch::Event", 0};
+static swig_type_info _swigt__p_PerlInterpreter = {"_p_PerlInterpreter", "PerlInterpreter *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_Session = {"_p_Session", "Session *", 0, 0, (void*)"freeswitch::Session", 0};
static swig_type_info _swigt__p_Stream = {"_p_Stream", "Stream *", 0, 0, (void*)"freeswitch::Stream", 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
@@ -6607,6 +6982,7 @@
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "switch_priority_t *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_switch_size_t = {"_p_switch_size_t", "switch_size_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -6615,6 +6991,7 @@
&_swigt__p_API,
&_swigt__p_CoreSession,
&_swigt__p_Event,
+ &_swigt__p_PerlInterpreter,
&_swigt__p_Session,
&_swigt__p_Stream,
&_swigt__p_char,
@@ -6627,6 +7004,7 @@
&_swigt__p_switch_input_args_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_priority_t,
+ &_swigt__p_switch_size_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_void,
@@ -6635,6 +7013,7 @@
static swig_cast_info _swigc__p_API[] = { {&_swigt__p_API, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_CoreSession[] = { {&_swigt__p_CoreSession, 0, 0, 0}, {&_swigt__p_Session, _p_SessionTo_p_CoreSession, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Event[] = { {&_swigt__p_Event, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_PerlInterpreter[] = { {&_swigt__p_PerlInterpreter, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Session[] = { {&_swigt__p_Session, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Stream[] = { {&_swigt__p_Stream, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
@@ -6647,6 +7026,7 @@
static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_priority_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_switch_size_t[] = { {&_swigt__p_switch_size_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -6655,6 +7035,7 @@
_swigc__p_API,
_swigc__p_CoreSession,
_swigc__p_Event,
+ _swigc__p_PerlInterpreter,
_swigc__p_Session,
_swigc__p_Stream,
_swigc__p_char,
@@ -6667,6 +7048,7 @@
_swigc__p_switch_input_args_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_priority_t,
+ _swigc__p_switch_size_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_void,
@@ -6777,6 +7159,16 @@
{"freeswitchc::Session_end_allow_threads", _wrap_Session_end_allow_threads},
{"freeswitchc::Session_check_hangup_hook", _wrap_Session_check_hangup_hook},
{"freeswitchc::Session_run_dtmf_callback", _wrap_Session_run_dtmf_callback},
+{"freeswitchc::Session_setInputCallback", _wrap_Session_setInputCallback},
+{"freeswitchc::Session_setHangupHook", _wrap_Session_setHangupHook},
+{"freeswitchc::Session_ready", _wrap_Session_ready},
+{"freeswitchc::Session_cb_function_set", _wrap_Session_cb_function_set},
+{"freeswitchc::Session_cb_function_get", _wrap_Session_cb_function_get},
+{"freeswitchc::Session_cb_arg_set", _wrap_Session_cb_arg_set},
+{"freeswitchc::Session_cb_arg_get", _wrap_Session_cb_arg_get},
+{"freeswitchc::Session_hangup_func_str_set", _wrap_Session_hangup_func_str_set},
+{"freeswitchc::Session_hangup_func_str_get", _wrap_Session_hangup_func_str_get},
+{"freeswitchc::Session_setPERL", _wrap_Session_setPERL},
{0,0}
};
/* -----------------------------------------------------------------------------
@@ -7096,3 +7488,4 @@
XSRETURN(1);
}
+#include "mod_perl_extra.c"
1
0
01 May '08
Author: anthm
Date: Thu May 1 16:22:53 2008
New Revision: 8240
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
update
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu May 1 16:22:53 2008
@@ -1517,7 +1517,7 @@
{
sofia_gateway_t *gateway = NULL;
- if (sofia_private->gateway_name) {
+ if (sofia_private && !switch_strlen_zero(sofia_private->gateway_name)) {
gateway = sofia_reg_find_gateway(sofia_private->gateway_name);
}
1
0
[commit] r8239 - in freeswitch/trunk/src: . include mod/languages/mod_java mod/languages/mod_java/src/org/freeswitch/swig mod/languages/mod_lua mod/languages/mod_perl
by Freeswitch SVN 01 May '08
by Freeswitch SVN 01 May '08
01 May '08
Author: brian
Date: Thu May 1 15:14:33 2008
New Revision: 8239
Modified:
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
freeswitch/trunk/src/switch_cpp.cpp
Log:
switch_size_t to int
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Thu May 1 15:14:33 2008
@@ -221,7 +221,7 @@
* receiving dtmf digits. For that, use collectDigits.
*/
SWITCH_DECLARE(char *) getDigits(
- switch_size_t maxdigits,
+ int maxdigits,
char *terminators,
char *terminator,
int timeout);
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java Thu May 1 15:14:33 2008
@@ -161,8 +161,8 @@
return freeswitchJNI.CoreSession_collectDigits(swigCPtr, this, timeout);
}
- public String getDigits(SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) {
- return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout);
+ public String getDigits(int maxdigits, String terminators, byte[] terminator, int timeout) {
+ return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, maxdigits, terminators, terminator, timeout);
}
public int transfer(String extensions, String dialplan, String context) {
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java Thu May 1 15:14:33 2008
@@ -87,7 +87,7 @@
public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_set_tts_parms(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_collectDigits(long jarg1, CoreSession jarg1_, int jarg2);
- public final static native String CoreSession_getDigits(long jarg1, CoreSession jarg1_, long jarg2, String jarg3, byte[] jarg4, int jarg5);
+ public final static native String CoreSession_getDigits(long jarg1, CoreSession jarg1_, int jarg2, String jarg3, byte[] jarg4, int jarg5);
public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp Thu May 1 15:14:33 2008
@@ -1576,26 +1576,20 @@
}
-SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jstring jarg3, jbyteArray jarg4, jint jarg5) {
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jstring jarg3, jbyteArray jarg4, jint jarg5) {
jstring jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
- switch_size_t arg2 ;
+ int arg2 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
int arg5 ;
char *result = 0 ;
- switch_size_t *argp2 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CoreSession **)&jarg1;
- argp2 = *(switch_size_t **)&jarg2;
- if (!argp2) {
- SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null switch_size_t");
- return 0;
- }
- arg2 = *argp2;
+ arg2 = (int)jarg2;
arg3 = 0;
if (jarg3) {
arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp Thu May 1 15:14:33 2008
@@ -1499,12 +1499,11 @@
#define SWIGTYPE_p_switch_input_args_t swig_types[12]
#define SWIGTYPE_p_switch_input_type_t swig_types[13]
#define SWIGTYPE_p_switch_priority_t swig_types[14]
-#define SWIGTYPE_p_switch_size_t swig_types[15]
-#define SWIGTYPE_p_switch_status_t swig_types[16]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[17]
-#define SWIGTYPE_p_void swig_types[18]
-static swig_type_info *swig_types[20];
-static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
+#define SWIGTYPE_p_switch_status_t swig_types[15]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[16]
+#define SWIGTYPE_p_void swig_types[17]
+static swig_type_info *swig_types[19];
+static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -4097,16 +4096,15 @@
static int _wrap_CoreSession_getDigits(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
- switch_size_t arg2 ;
+ int arg2 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
int arg5 ;
char *result = 0 ;
- switch_size_t *argp2 ;
SWIG_check_num_args("getDigits",5,5)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getDigits",1,"CoreSession *");
- if(!lua_isuserdata(L,2)) SWIG_fail_arg("getDigits",2,"switch_size_t");
+ if(!lua_isnumber(L,2)) SWIG_fail_arg("getDigits",2,"int");
if(!lua_isstring(L,3)) SWIG_fail_arg("getDigits",3,"char *");
if(!lua_isstring(L,4)) SWIG_fail_arg("getDigits",4,"char *");
if(!lua_isnumber(L,5)) SWIG_fail_arg("getDigits",5,"int");
@@ -4115,12 +4113,7 @@
SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
}
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_size_t,0))){
- SWIG_fail_ptr("CoreSession_getDigits",2,SWIGTYPE_p_switch_size_t);
- }
- arg2 = *argp2;
-
+ arg2 = (int)lua_tonumber(L, 2);
arg3 = (char *)lua_tostring(L, 3);
arg4 = (char *)lua_tostring(L, 4);
arg5 = (int)lua_tonumber(L, 5);
@@ -5493,7 +5486,6 @@
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "switch_priority_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_switch_size_t = {"_p_switch_size_t", "switch_size_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -5514,7 +5506,6 @@
&_swigt__p_switch_input_args_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_priority_t,
- &_swigt__p_switch_size_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_void,
@@ -5535,7 +5526,6 @@
static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_priority_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_size_t[] = { {&_swigt__p_switch_size_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -5556,7 +5546,6 @@
_swigc__p_switch_input_args_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_priority_t,
- _swigc__p_switch_size_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_void,
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Thu May 1 15:14:33 2008
@@ -1461,12 +1461,11 @@
#define SWIGTYPE_p_switch_input_args_t swig_types[12]
#define SWIGTYPE_p_switch_input_type_t swig_types[13]
#define SWIGTYPE_p_switch_priority_t swig_types[14]
-#define SWIGTYPE_p_switch_size_t swig_types[15]
-#define SWIGTYPE_p_switch_status_t swig_types[16]
-#define SWIGTYPE_p_switch_stream_handle_t swig_types[17]
-#define SWIGTYPE_p_void swig_types[18]
-static swig_type_info *swig_types[20];
-static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0};
+#define SWIGTYPE_p_switch_status_t swig_types[15]
+#define SWIGTYPE_p_switch_stream_handle_t swig_types[16]
+#define SWIGTYPE_p_void swig_types[17]
+static swig_type_info *swig_types[19];
+static swig_module_info swig_module = {swig_types, 18, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
@@ -5223,15 +5222,15 @@
XS(_wrap_CoreSession_getDigits) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
- switch_size_t arg2 ;
+ int arg2 ;
char *arg3 = (char *) 0 ;
char *arg4 = (char *) 0 ;
int arg5 ;
char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 ;
- int res2 = 0 ;
+ int val2 ;
+ int ecode2 = 0 ;
int res3 ;
char *buf3 = 0 ;
int alloc3 = 0 ;
@@ -5251,17 +5250,11 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- {
- res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_switch_size_t, 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
- }
- if (!argp2) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
- } else {
- arg2 = *(reinterpret_cast< switch_size_t * >(argp2));
- }
- }
+ ecode2 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(1), &val2);
+ if (!SWIG_IsOK(ecode2)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "int""'");
+ }
+ arg2 = static_cast< int >(val2);
res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
if (!SWIG_IsOK(res3)) {
SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'");
@@ -5280,12 +5273,14 @@
result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
+
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
XSRETURN(argvi);
fail:
+
if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
@@ -6612,7 +6607,6 @@
static swig_type_info _swigt__p_switch_input_args_t = {"_p_switch_input_args_t", "switch_input_args_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_input_type_t = {"_p_switch_input_type_t", "switch_input_type_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_priority_t = {"_p_switch_priority_t", "switch_priority_t *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_switch_size_t = {"_p_switch_size_t", "switch_size_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_status_t = {"_p_switch_status_t", "switch_status_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_switch_stream_handle_t = {"_p_switch_stream_handle_t", "switch_stream_handle_t *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_void = {"_p_void", "void *", 0, 0, (void*)0, 0};
@@ -6633,7 +6627,6 @@
&_swigt__p_switch_input_args_t,
&_swigt__p_switch_input_type_t,
&_swigt__p_switch_priority_t,
- &_swigt__p_switch_size_t,
&_swigt__p_switch_status_t,
&_swigt__p_switch_stream_handle_t,
&_swigt__p_void,
@@ -6654,7 +6647,6 @@
static swig_cast_info _swigc__p_switch_input_args_t[] = { {&_swigt__p_switch_input_args_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_input_type_t[] = { {&_swigt__p_switch_input_type_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_priority_t[] = { {&_swigt__p_switch_priority_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_switch_size_t[] = { {&_swigt__p_switch_size_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_status_t[] = { {&_swigt__p_switch_status_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_switch_stream_handle_t[] = { {&_swigt__p_switch_stream_handle_t, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_void[] = { {&_swigt__p_void, 0, 0, 0},{0, 0, 0, 0}};
@@ -6675,7 +6667,6 @@
_swigc__p_switch_input_args_t,
_swigc__p_switch_input_type_t,
_swigc__p_switch_priority_t,
- _swigc__p_switch_size_t,
_swigc__p_switch_status_t,
_swigc__p_switch_stream_handle_t,
_swigc__p_void,
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Thu May 1 15:14:33 2008
@@ -470,7 +470,7 @@
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(char *) CoreSession::getDigits(switch_size_t maxdigits,
+SWITCH_DECLARE(char *) CoreSession::getDigits(int maxdigits,
char *terminators,
char *terminator,
int timeout)
1
0
[commit] r8238 - in freeswitch/trunk: scripts/lua src src/include src/mod/languages/mod_java src/mod/languages/mod_java/src/org/freeswitch/swig src/mod/languages/mod_lua src/mod/languages/mod_perl src/mod/languages/mod_python
by Freeswitch SVN 01 May '08
by Freeswitch SVN 01 May '08
01 May '08
Author: anthm
Date: Thu May 1 15:03:57 2008
New Revision: 8238
Modified:
freeswitch/trunk/scripts/lua/mwi_event.lua
freeswitch/trunk/scripts/lua/originate.lua
freeswitch/trunk/src/include/switch_cpp.h
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
freeswitch/trunk/src/switch_cpp.cpp
freeswitch/trunk/src/switch_ivr_play_say.c
Log:
fix bad pointer memory snafu in wrapped language libs
Modified: freeswitch/trunk/scripts/lua/mwi_event.lua
==============================================================================
--- freeswitch/trunk/scripts/lua/mwi_event.lua (original)
+++ freeswitch/trunk/scripts/lua/mwi_event.lua Thu May 1 15:03:57 2008
@@ -3,6 +3,6 @@
freeswitch.console_log("info", "Lua in da house!!!\n");
local event = freeswitch.Event("message_waiting");
-event:addHeader("MWI-Messages-Waiting", "yes");
+event:addHeader("MWI-Messages-Waiting", "no");
event:addHeader("MWI-Message-Account", "sip:1000@10.0.1.100");
event:fire();
Modified: freeswitch/trunk/scripts/lua/originate.lua
==============================================================================
--- freeswitch/trunk/scripts/lua/originate.lua (original)
+++ freeswitch/trunk/scripts/lua/originate.lua Thu May 1 15:03:57 2008
@@ -1,6 +1,6 @@
-- Example Lua script to originate. luarun
freeswitch.console_log("info", "Lua in da house!!!\n");
-local session = freeswitch.Session("sofia/10.0.1.100/1002");
+local session = freeswitch.Session("sofia/10.0.1.100/1001");
session:execute("playback", "/sr8k.wav");
session:hangup();
Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h (original)
+++ freeswitch/trunk/src/include/switch_cpp.h Thu May 1 15:03:57 2008
@@ -140,6 +140,7 @@
void *on_hangup; // language specific callback function, cast as void *
switch_file_handle_t local_fh;
switch_file_handle_t *fhp;
+ char dtmf_buf[512];
SWITCH_DECLARE(switch_status_t) process_callback_result(char *ret);
public:
SWITCH_DECLARE_CONSTRUCTOR CoreSession();
@@ -219,13 +220,12 @@
* (see mod_python.i). This does NOT call any callbacks upon
* receiving dtmf digits. For that, use collectDigits.
*/
- SWITCH_DECLARE(int) getDigits(char *dtmf_buf,
- switch_size_t buflen,
- switch_size_t maxdigits,
- char *terminators,
- char *terminator,
- int timeout);
-
+ SWITCH_DECLARE(char *) getDigits(
+ switch_size_t maxdigits,
+ char *terminators,
+ char *terminator,
+ int timeout);
+
SWITCH_DECLARE(int) transfer(char *extensions, char *dialplan, char *context);
/** \brief Play a file into channel and collect dtmfs
@@ -236,14 +236,13 @@
* setDTMFCallback(..) as it uses its own internal callback
* handler.
*/
- SWITCH_DECLARE(int) playAndGetDigits(int min_digits,
+ SWITCH_DECLARE(char *) playAndGetDigits(int min_digits,
int max_digits,
int max_tries,
int timeout,
char *terminators,
char *audio_files,
char *bad_input_audio_files,
- char *dtmf_buf,
char *digits_regex);
/** \brief Play a file that resides on disk into the channel
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java Thu May 1 15:03:57 2008
@@ -161,16 +161,16 @@
return freeswitchJNI.CoreSession_collectDigits(swigCPtr, this, timeout);
}
- public int getDigits(byte[] dtmf_buf, SWIGTYPE_p_switch_size_t buflen, SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) {
- return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, dtmf_buf, SWIGTYPE_p_switch_size_t.getCPtr(buflen), SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout);
+ public String getDigits(SWIGTYPE_p_switch_size_t maxdigits, String terminators, byte[] terminator, int timeout) {
+ return freeswitchJNI.CoreSession_getDigits(swigCPtr, this, SWIGTYPE_p_switch_size_t.getCPtr(maxdigits), terminators, terminator, timeout);
}
public int transfer(String extensions, String dialplan, String context) {
return freeswitchJNI.CoreSession_transfer(swigCPtr, this, extensions, dialplan, context);
}
- public int playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, byte[] dtmf_buf, String digits_regex) {
- return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, dtmf_buf, digits_regex);
+ public String playAndGetDigits(int min_digits, int max_digits, int max_tries, int timeout, String terminators, String audio_files, String bad_input_audio_files, String digits_regex) {
+ return freeswitchJNI.CoreSession_playAndGetDigits(swigCPtr, this, min_digits, max_digits, max_tries, timeout, terminators, audio_files, bad_input_audio_files, digits_regex);
}
public int streamFile(String file, int starting_sample_count) {
Modified: freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java Thu May 1 15:03:57 2008
@@ -87,9 +87,9 @@
public final static native int CoreSession_speak(long jarg1, CoreSession jarg1_, String jarg2);
public final static native void CoreSession_set_tts_parms(long jarg1, CoreSession jarg1_, String jarg2, String jarg3);
public final static native int CoreSession_collectDigits(long jarg1, CoreSession jarg1_, int jarg2);
- public final static native int CoreSession_getDigits(long jarg1, CoreSession jarg1_, byte[] jarg2, long jarg3, long jarg4, String jarg5, byte[] jarg6, int jarg7);
+ public final static native String CoreSession_getDigits(long jarg1, CoreSession jarg1_, long jarg2, String jarg3, byte[] jarg4, int jarg5);
public final static native int CoreSession_transfer(long jarg1, CoreSession jarg1_, String jarg2, String jarg3, String jarg4);
- public final static native int CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, byte[] jarg9, String jarg10);
+ public final static native String CoreSession_playAndGetDigits(long jarg1, CoreSession jarg1_, int jarg2, int jarg3, int jarg4, int jarg5, String jarg6, String jarg7, String jarg8, String jarg9);
public final static native int CoreSession_streamFile__SWIG_0(long jarg1, CoreSession jarg1_, String jarg2, int jarg3);
public final static native int CoreSession_streamFile__SWIG_1(long jarg1, CoreSession jarg1_, String jarg2);
public final static native int CoreSession_flushEvents(long jarg1, CoreSession jarg1_);
Modified: freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_java/switch_swig_wrap.cpp Thu May 1 15:03:57 2008
@@ -1576,59 +1576,42 @@
}
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jbyteArray jarg2, jlong jarg3, jlong jarg4, jstring jarg5, jbyteArray jarg6, jint jarg7) {
- jint jresult = 0 ;
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1getDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jstring jarg3, jbyteArray jarg4, jint jarg5) {
+ jstring jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- switch_size_t arg3 ;
- switch_size_t arg4 ;
- char *arg5 = (char *) 0 ;
- char *arg6 = (char *) 0 ;
- int arg7 ;
- int result;
- switch_size_t *argp3 ;
- switch_size_t *argp4 ;
+ switch_size_t arg2 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ int arg5 ;
+ char *result = 0 ;
+ switch_size_t *argp2 ;
(void)jenv;
(void)jcls;
(void)jarg1_;
arg1 = *(CoreSession **)&jarg1;
- {
- arg2 = (char*) jenv->GetByteArrayElements(jarg2, 0);
- if (!arg2) return 0;
- }
- argp3 = *(switch_size_t **)&jarg3;
- if (!argp3) {
- SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null switch_size_t");
- return 0;
- }
- arg3 = *argp3;
- argp4 = *(switch_size_t **)&jarg4;
- if (!argp4) {
+ argp2 = *(switch_size_t **)&jarg2;
+ if (!argp2) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null switch_size_t");
return 0;
}
- arg4 = *argp4;
- arg5 = 0;
- if (jarg5) {
- arg5 = (char *)jenv->GetStringUTFChars(jarg5, 0);
- if (!arg5) return 0;
- }
- {
- arg6 = (char*) jenv->GetByteArrayElements(jarg6, 0);
- if (!arg6) return 0;
+ arg2 = *argp2;
+ arg3 = 0;
+ if (jarg3) {
+ arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
+ if (!arg3) return 0;
}
- arg7 = (int)jarg7;
- result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
- jresult = (jint)result;
{
- jenv->ReleaseByteArrayElements(jarg2, (jbyte*) arg2, 0);
+ arg4 = (char*) jenv->GetByteArrayElements(jarg4, 0);
+ if (!arg4) return 0;
}
+ arg5 = (int)jarg5;
+ result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
+ if(result) jresult = jenv->NewStringUTF((const char *)result);
{
- jenv->ReleaseByteArrayElements(jarg6, (jbyte*) arg6, 0);
+ jenv->ReleaseByteArrayElements(jarg4, (jbyte*) arg4, 0);
}
-
- if (arg5) jenv->ReleaseStringUTFChars(jarg5, (const char *)arg5);
+ if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
return jresult;
}
@@ -1670,8 +1653,8 @@
}
-SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jbyteArray jarg9, jstring jarg10) {
- jint jresult = 0 ;
+SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_CoreSession_1playAndGetDigits(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jstring jarg6, jstring jarg7, jstring jarg8, jstring jarg9) {
+ jstring jresult = 0 ;
CoreSession *arg1 = (CoreSession *) 0 ;
int arg2 ;
int arg3 ;
@@ -1681,8 +1664,7 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
- int result;
+ char *result = 0 ;
(void)jenv;
(void)jcls;
@@ -1707,25 +1689,17 @@
arg8 = (char *)jenv->GetStringUTFChars(jarg8, 0);
if (!arg8) return 0;
}
- {
- arg9 = (char*) jenv->GetByteArrayElements(jarg9, 0);
+ arg9 = 0;
+ if (jarg9) {
+ arg9 = (char *)jenv->GetStringUTFChars(jarg9, 0);
if (!arg9) return 0;
}
- arg10 = 0;
- if (jarg10) {
- arg10 = (char *)jenv->GetStringUTFChars(jarg10, 0);
- if (!arg10) return 0;
- }
- result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
- jresult = (jint)result;
- {
- jenv->ReleaseByteArrayElements(jarg9, (jbyte*) arg9, 0);
- }
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ if(result) jresult = jenv->NewStringUTF((const char *)result);
if (arg6) jenv->ReleaseStringUTFChars(jarg6, (const char *)arg6);
if (arg7) jenv->ReleaseStringUTFChars(jarg7, (const char *)arg7);
if (arg8) jenv->ReleaseStringUTFChars(jarg8, (const char *)arg8);
-
- if (arg10) jenv->ReleaseStringUTFChars(jarg10, (const char *)arg10);
+ if (arg9) jenv->ReleaseStringUTFChars(jarg9, (const char *)arg9);
return jresult;
}
Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp Thu May 1 15:03:57 2008
@@ -4097,48 +4097,36 @@
static int _wrap_CoreSession_getDigits(lua_State* L) {
int SWIG_arg = -1;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- switch_size_t arg3 ;
- switch_size_t arg4 ;
- char *arg5 = (char *) 0 ;
- char *arg6 = (char *) 0 ;
- int arg7 ;
- int result;
- switch_size_t *argp3 ;
- switch_size_t *argp4 ;
+ switch_size_t arg2 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ int arg5 ;
+ char *result = 0 ;
+ switch_size_t *argp2 ;
- SWIG_check_num_args("getDigits",7,7)
+ SWIG_check_num_args("getDigits",5,5)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("getDigits",1,"CoreSession *");
- if(!lua_isstring(L,2)) SWIG_fail_arg("getDigits",2,"char *");
- if(!lua_isuserdata(L,3)) SWIG_fail_arg("getDigits",3,"switch_size_t");
- if(!lua_isuserdata(L,4)) SWIG_fail_arg("getDigits",4,"switch_size_t");
- if(!lua_isstring(L,5)) SWIG_fail_arg("getDigits",5,"char *");
- if(!lua_isstring(L,6)) SWIG_fail_arg("getDigits",6,"char *");
- if(!lua_isnumber(L,7)) SWIG_fail_arg("getDigits",7,"int");
+ if(!lua_isuserdata(L,2)) SWIG_fail_arg("getDigits",2,"switch_size_t");
+ if(!lua_isstring(L,3)) SWIG_fail_arg("getDigits",3,"char *");
+ if(!lua_isstring(L,4)) SWIG_fail_arg("getDigits",4,"char *");
+ if(!lua_isnumber(L,5)) SWIG_fail_arg("getDigits",5,"int");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_getDigits",1,SWIGTYPE_p_CoreSession);
}
- arg2 = (char *)lua_tostring(L, 2);
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,3,(void**)&argp3,SWIGTYPE_p_switch_size_t,0))){
- SWIG_fail_ptr("CoreSession_getDigits",3,SWIGTYPE_p_switch_size_t);
- }
- arg3 = *argp3;
-
- if (!SWIG_IsOK(SWIG_ConvertPtr(L,4,(void**)&argp4,SWIGTYPE_p_switch_size_t,0))){
- SWIG_fail_ptr("CoreSession_getDigits",4,SWIGTYPE_p_switch_size_t);
+ if (!SWIG_IsOK(SWIG_ConvertPtr(L,2,(void**)&argp2,SWIGTYPE_p_switch_size_t,0))){
+ SWIG_fail_ptr("CoreSession_getDigits",2,SWIGTYPE_p_switch_size_t);
}
- arg4 = *argp4;
+ arg2 = *argp2;
- arg5 = (char *)lua_tostring(L, 5);
- arg6 = (char *)lua_tostring(L, 6);
- arg7 = (int)lua_tonumber(L, 7);
- result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
+ arg3 = (char *)lua_tostring(L, 3);
+ arg4 = (char *)lua_tostring(L, 4);
+ arg5 = (int)lua_tonumber(L, 5);
+ result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
SWIG_arg=0;
- lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+ lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
@@ -4194,10 +4182,9 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
- int result;
+ char *result = 0 ;
- SWIG_check_num_args("playAndGetDigits",10,10)
+ SWIG_check_num_args("playAndGetDigits",9,9)
if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("playAndGetDigits",1,"CoreSession *");
if(!lua_isnumber(L,2)) SWIG_fail_arg("playAndGetDigits",2,"int");
if(!lua_isnumber(L,3)) SWIG_fail_arg("playAndGetDigits",3,"int");
@@ -4207,7 +4194,6 @@
if(!lua_isstring(L,7)) SWIG_fail_arg("playAndGetDigits",7,"char *");
if(!lua_isstring(L,8)) SWIG_fail_arg("playAndGetDigits",8,"char *");
if(!lua_isstring(L,9)) SWIG_fail_arg("playAndGetDigits",9,"char *");
- if(!lua_isstring(L,10)) SWIG_fail_arg("playAndGetDigits",10,"char *");
if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_CoreSession,0))){
SWIG_fail_ptr("CoreSession_playAndGetDigits",1,SWIGTYPE_p_CoreSession);
@@ -4221,10 +4207,9 @@
arg7 = (char *)lua_tostring(L, 7);
arg8 = (char *)lua_tostring(L, 8);
arg9 = (char *)lua_tostring(L, 9);
- arg10 = (char *)lua_tostring(L, 10);
- result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
SWIG_arg=0;
- lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+ lua_pushstring(L,(const char*)result); SWIG_arg++;
return SWIG_arg;
if(0) SWIG_fail;
Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp Thu May 1 15:03:57 2008
@@ -5223,96 +5223,71 @@
XS(_wrap_CoreSession_getDigits) {
{
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- switch_size_t arg3 ;
- switch_size_t arg4 ;
- char *arg5 = (char *) 0 ;
- char *arg6 = (char *) 0 ;
- int arg7 ;
- int result;
+ switch_size_t arg2 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ int arg5 ;
+ char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- int res2 ;
- char *buf2 = 0 ;
- int alloc2 = 0 ;
- void *argp3 ;
- int res3 = 0 ;
- void *argp4 ;
- int res4 = 0 ;
- int res5 ;
- char *buf5 = 0 ;
- int alloc5 = 0 ;
- int res6 ;
- char *buf6 = 0 ;
- int alloc6 = 0 ;
- int val7 ;
- int ecode7 = 0 ;
+ void *argp2 ;
+ int res2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char *buf4 = 0 ;
+ int alloc4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
int argvi = 0;
dXSARGS;
- if ((items < 7) || (items > 7)) {
- SWIG_croak("Usage: CoreSession_getDigits(self,dtmf_buf,buflen,maxdigits,terminators,terminator,timeout);");
+ if ((items < 5) || (items > 5)) {
+ SWIG_croak("Usage: CoreSession_getDigits(self,maxdigits,terminators,terminator,timeout);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *""'");
- }
- arg2 = reinterpret_cast< char * >(buf2);
{
- res3 = SWIG_ConvertPtr(ST(2), &argp3, SWIGTYPE_p_switch_size_t, 0 );
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'");
+ res2 = SWIG_ConvertPtr(ST(1), &argp2, SWIGTYPE_p_switch_size_t, 0 );
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
}
- if (!argp3) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'");
+ if (!argp2) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
} else {
- arg3 = *(reinterpret_cast< switch_size_t * >(argp3));
+ arg2 = *(reinterpret_cast< switch_size_t * >(argp2));
}
}
- {
- res4 = SWIG_ConvertPtr(ST(3), &argp4, SWIGTYPE_p_switch_size_t, 0 );
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'");
- }
- if (!argp4) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'");
- } else {
- arg4 = *(reinterpret_cast< switch_size_t * >(argp4));
- }
- }
- res5 = SWIG_AsCharPtrAndSize(ST(4), &buf5, NULL, &alloc5);
- if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'");
+ res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'");
}
- arg5 = reinterpret_cast< char * >(buf5);
- res6 = SWIG_AsCharPtrAndSize(ST(5), &buf6, NULL, &alloc6);
- if (!SWIG_IsOK(res6)) {
- SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "char *""'");
+ arg3 = reinterpret_cast< char * >(buf3);
+ res4 = SWIG_AsCharPtrAndSize(ST(3), &buf4, NULL, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *""'");
}
- arg6 = reinterpret_cast< char * >(buf6);
- ecode7 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(6), &val7);
- if (!SWIG_IsOK(ecode7)) {
- SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "CoreSession_getDigits" "', argument " "7"" of type '" "int""'");
+ arg4 = reinterpret_cast< char * >(buf4);
+ ecode5 = SWIG_AsVal_int SWIG_PERL_CALL_ARGS_2(ST(4), &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "int""'");
}
- arg7 = static_cast< int >(val7);
- result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
- ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+ arg5 = static_cast< int >(val5);
+ result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
- if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
- if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
XSRETURN(argvi);
fail:
- if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
- if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
- if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+ if (alloc4 == SWIG_NEWOBJ) delete[] buf4;
SWIG_croak_null();
}
@@ -5391,8 +5366,7 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
- int result;
+ char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
@@ -5415,14 +5389,11 @@
int res9 ;
char *buf9 = 0 ;
int alloc9 = 0 ;
- int res10 ;
- char *buf10 = 0 ;
- int alloc10 = 0 ;
int argvi = 0;
dXSARGS;
- if ((items < 10) || (items > 10)) {
- SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,dtmf_buf,digits_regex);");
+ if ((items < 9) || (items > 9)) {
+ SWIG_croak("Usage: CoreSession_playAndGetDigits(self,min_digits,max_digits,max_tries,timeout,terminators,audio_files,bad_input_audio_files,digits_regex);");
}
res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
@@ -5469,13 +5440,8 @@
SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
}
arg9 = reinterpret_cast< char * >(buf9);
- res10 = SWIG_AsCharPtrAndSize(ST(9), &buf10, NULL, &alloc10);
- if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
- }
- arg10 = reinterpret_cast< char * >(buf10);
- result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
- ST(argvi) = SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ ST(argvi) = SWIG_FromCharPtr((const char *)result); argvi++ ;
@@ -5485,7 +5451,6 @@
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
- if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
XSRETURN(argvi);
fail:
@@ -5497,7 +5462,6 @@
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
- if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
SWIG_croak_null();
}
}
Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp (original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp Thu May 1 15:03:57 2008
@@ -5631,112 +5631,77 @@
SWIGINTERN PyObject *_wrap_CoreSession_getDigits(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
CoreSession *arg1 = (CoreSession *) 0 ;
- char *arg2 = (char *) 0 ;
- switch_size_t arg3 ;
- switch_size_t arg4 ;
- char *arg5 = (char *) 0 ;
- char *arg6 = (char *) 0 ;
- int arg7 ;
- int result;
+ switch_size_t arg2 ;
+ char *arg3 = (char *) 0 ;
+ char *arg4 = (char *) 0 ;
+ int arg5 ;
+ char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
- int res2 ;
- char temp2[128+1] ;
- char *t2 = 0 ;
- size_t n2 = 0 ;
- int alloc2 = 0 ;
- void *argp3 ;
- int res3 = 0 ;
- void *argp4 ;
- int res4 = 0 ;
- int res5 ;
- char *buf5 = 0 ;
- int alloc5 = 0 ;
- int res6 ;
- char temp6[8+1] ;
- char *t6 = 0 ;
- size_t n6 = 0 ;
- int alloc6 = 0 ;
- int val7 ;
- int ecode7 = 0 ;
+ void *argp2 ;
+ int res2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ int res4 ;
+ char temp4[8+1] ;
+ char *t4 = 0 ;
+ size_t n4 = 0 ;
+ int alloc4 = 0 ;
+ int val5 ;
+ int ecode5 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
- PyObject * obj5 = 0 ;
- PyObject * obj6 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOOOO:CoreSession_getDigits",&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_getDigits" "', argument " "1"" of type '" "CoreSession *""'");
}
arg1 = reinterpret_cast< CoreSession * >(argp1);
- res2 = SWIG_AsCharPtrAndSize(obj1, &t2, &n2, &alloc2);
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "char *dtmf_buf""'");
- }
- if ( n2 > (size_t) 128 ) n2 = (size_t) 128;
- memcpy(temp2, t2, sizeof(char)*n2);
- if (alloc2 == SWIG_NEWOBJ) delete[] t2;
- temp2[n2 - 1] = 0;
- arg2 = (char *) temp2;
{
- res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_switch_size_t, 0 | 0);
- if (!SWIG_IsOK(res3)) {
- SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'");
+ res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_switch_size_t, 0 | 0);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
}
- if (!argp3) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "switch_size_t""'");
+ if (!argp2) {
+ SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "2"" of type '" "switch_size_t""'");
} else {
- switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp3);
- arg3 = *temp;
- if (SWIG_IsNewObj(res3)) delete temp;
+ switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp2);
+ arg2 = *temp;
+ if (SWIG_IsNewObj(res2)) delete temp;
}
}
- {
- res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_switch_size_t, 0 | 0);
- if (!SWIG_IsOK(res4)) {
- SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'");
- }
- if (!argp4) {
- SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "switch_size_t""'");
- } else {
- switch_size_t * temp = reinterpret_cast< switch_size_t * >(argp4);
- arg4 = *temp;
- if (SWIG_IsNewObj(res4)) delete temp;
- }
- }
- res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5);
- if (!SWIG_IsOK(res5)) {
- SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "char *""'");
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "CoreSession_getDigits" "', argument " "3"" of type '" "char *""'");
}
- arg5 = reinterpret_cast< char * >(buf5);
- res6 = SWIG_AsCharPtrAndSize(obj5, &t6, &n6, &alloc6);
- if (!SWIG_IsOK(res6)) {
- SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "CoreSession_getDigits" "', argument " "6"" of type '" "char *terminator""'");
+ arg3 = reinterpret_cast< char * >(buf3);
+ res4 = SWIG_AsCharPtrAndSize(obj3, &t4, &n4, &alloc4);
+ if (!SWIG_IsOK(res4)) {
+ SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "CoreSession_getDigits" "', argument " "4"" of type '" "char *terminator""'");
}
- if ( n6 > (size_t) 8 ) n6 = (size_t) 8;
- memcpy(temp6, t6, sizeof(char)*n6);
- if (alloc6 == SWIG_NEWOBJ) delete[] t6;
- temp6[n6 - 1] = 0;
- arg6 = (char *) temp6;
- ecode7 = SWIG_AsVal_int(obj6, &val7);
- if (!SWIG_IsOK(ecode7)) {
- SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "CoreSession_getDigits" "', argument " "7"" of type '" "int""'");
+ if ( n4 > (size_t) 8 ) n4 = (size_t) 8;
+ memcpy(temp4, t4, sizeof(char)*n4);
+ if (alloc4 == SWIG_NEWOBJ) delete[] t4;
+ temp4[n4 - 1] = 0;
+ arg4 = (char *) temp4;
+ ecode5 = SWIG_AsVal_int(obj4, &val5);
+ if (!SWIG_IsOK(ecode5)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "CoreSession_getDigits" "', argument " "5"" of type '" "int""'");
}
- arg7 = static_cast< int >(val7);
- result = (int)(arg1)->getDigits(arg2,arg3,arg4,arg5,arg6,arg7);
- resultobj = SWIG_From_int(static_cast< int >(result));
- arg2[128] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg2));
- arg6[8] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg6));
- if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
+ arg5 = static_cast< int >(val5);
+ result = (char *)(arg1)->getDigits(arg2,arg3,arg4,arg5);
+ resultobj = SWIG_FromCharPtr((const char *)result);
+ arg4[8] = 0;
+ resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg4));
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return resultobj;
fail:
- if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
+ if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
return NULL;
}
@@ -5810,8 +5775,7 @@
char *arg7 = (char *) 0 ;
char *arg8 = (char *) 0 ;
char *arg9 = (char *) 0 ;
- char *arg10 = (char *) 0 ;
- int result;
+ char *result = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
@@ -5832,13 +5796,8 @@
char *buf8 = 0 ;
int alloc8 = 0 ;
int res9 ;
- char temp9[128+1] ;
- char *t9 = 0 ;
- size_t n9 = 0 ;
+ char *buf9 = 0 ;
int alloc9 = 0 ;
- int res10 ;
- char *buf10 = 0 ;
- int alloc10 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
@@ -5848,9 +5807,8 @@
PyObject * obj6 = 0 ;
PyObject * obj7 = 0 ;
PyObject * obj8 = 0 ;
- PyObject * obj9 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:CoreSession_playAndGetDigits",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CoreSession, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CoreSession_playAndGetDigits" "', argument " "1"" of type '" "CoreSession *""'");
@@ -5891,34 +5849,23 @@
SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "CoreSession_playAndGetDigits" "', argument " "8"" of type '" "char *""'");
}
arg8 = reinterpret_cast< char * >(buf8);
- res9 = SWIG_AsCharPtrAndSize(obj8, &t9, &n9, &alloc9);
+ res9 = SWIG_AsCharPtrAndSize(obj8, &buf9, NULL, &alloc9);
if (!SWIG_IsOK(res9)) {
- SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *dtmf_buf""'");
+ SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "CoreSession_playAndGetDigits" "', argument " "9"" of type '" "char *""'");
}
- if ( n9 > (size_t) 128 ) n9 = (size_t) 128;
- memcpy(temp9, t9, sizeof(char)*n9);
- if (alloc9 == SWIG_NEWOBJ) delete[] t9;
- temp9[n9 - 1] = 0;
- arg9 = (char *) temp9;
- res10 = SWIG_AsCharPtrAndSize(obj9, &buf10, NULL, &alloc10);
- if (!SWIG_IsOK(res10)) {
- SWIG_exception_fail(SWIG_ArgError(res10), "in method '" "CoreSession_playAndGetDigits" "', argument " "10"" of type '" "char *""'");
- }
- arg10 = reinterpret_cast< char * >(buf10);
- result = (int)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);
- resultobj = SWIG_From_int(static_cast< int >(result));
- arg9[128] = 0;
- resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_FromCharPtr(arg9));
+ arg9 = reinterpret_cast< char * >(buf9);
+ result = (char *)(arg1)->playAndGetDigits(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ resultobj = SWIG_FromCharPtr((const char *)result);
if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
- if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
return resultobj;
fail:
if (alloc6 == SWIG_NEWOBJ) delete[] buf6;
if (alloc7 == SWIG_NEWOBJ) delete[] buf7;
if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
- if (alloc10 == SWIG_NEWOBJ) delete[] buf10;
+ if (alloc9 == SWIG_NEWOBJ) delete[] buf9;
return NULL;
}
Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp (original)
+++ freeswitch/trunk/src/switch_cpp.cpp Thu May 1 15:03:57 2008
@@ -470,20 +470,19 @@
return SWITCH_STATUS_SUCCESS;
}
-SWITCH_DECLARE(int) CoreSession::getDigits(char *dtmf_buf,
- switch_size_t buflen,
- switch_size_t maxdigits,
- char *terminators,
- char *terminator,
- int timeout)
+SWITCH_DECLARE(char *) CoreSession::getDigits(switch_size_t maxdigits,
+ char *terminators,
+ char *terminator,
+ int timeout)
{
switch_status_t status;
- sanity_check(-1);
+ sanity_check("");
begin_allow_threads();
+ memset(dtmf_buf, 0, sizeof(dtmf_buf));
status = switch_ivr_collect_digits_count(session,
dtmf_buf,
- buflen,
+ sizeof(dtmf_buf),
maxdigits,
terminators,
terminator,
@@ -491,7 +490,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "getDigits dtmf_buf: %s\n", dtmf_buf);
end_allow_threads();
- return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
+ return dtmf_buf;
}
SWITCH_DECLARE(int) CoreSession::transfer(char *extension, char *dialplan, char *context)
@@ -505,19 +504,19 @@
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
-SWITCH_DECLARE(int) CoreSession::playAndGetDigits(int min_digits,
- int max_digits,
- int max_tries,
- int timeout,
- char *terminators,
- char *audio_files,
- char *bad_input_audio_files,
- char *dtmf_buf,
- char *digits_regex)
+SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
+ int max_digits,
+ int max_tries,
+ int timeout,
+ char *terminators,
+ char *audio_files,
+ char *bad_input_audio_files,
+ char *digits_regex)
{
switch_status_t status;
- sanity_check(-1);
+ sanity_check("");
begin_allow_threads();
+ memset(dtmf_buf, 0, sizeof(dtmf_buf));
status = switch_play_and_get_digits( session,
(uint32_t) min_digits,
(uint32_t) max_digits,
@@ -527,13 +526,13 @@
audio_files,
bad_input_audio_files,
dtmf_buf,
- 128,
+ sizeof(dtmf_buf),
digits_regex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "playAndGetDigits dtmf_buf: %s\n", dtmf_buf);
end_allow_threads();
- return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
+ return dtmf_buf;
}
SWITCH_DECLARE(int) CoreSession::streamFile(char *file, int starting_sample_count) {
Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c (original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c Thu May 1 15:03:57 2008
@@ -1239,7 +1239,7 @@
switch_channel_pre_answer(channel);
//Start pestering the user for input
- for (; (switch_channel_get_state(channel) == CS_EXECUTE) && max_tries > 0; max_tries--) {
+ for (; switch_channel_ready(channel) && max_tries > 0; max_tries--) {
switch_input_args_t args = { 0 };
//make the buffer so fresh and so clean clean
memset(digit_buffer, 0, digit_buffer_length);
1
0
[commit] r8237 - in freeswitch/trunk/src: include mod/endpoints/mod_sofia
by Freeswitch SVN 01 May '08
by Freeswitch SVN 01 May '08
01 May '08
Author: anthm
Date: Thu May 1 14:35:45 2008
New Revision: 8237
Modified:
freeswitch/trunk/src/include/switch_types.h
freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Log:
let sip calls pass the exact response status across a bridge
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Thu May 1 14:35:45 2008
@@ -102,6 +102,7 @@
#define SWITCH_PATH_SEPARATOR "/"
#endif
#define SWITCH_URL_SEPARATOR "://"
+#define SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE "proto_specific_hangup_cause"
#define SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE "execute_on_answer"
#define SWITCH_CALL_TIMEOUT_VARIABLE "call_timeout"
#define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid"
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c Thu May 1 14:35:45 2008
@@ -222,7 +222,14 @@
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_call_cause_t cause = switch_channel_get_cause(channel);
int sip_cause = hangup_cause_to_sip(cause);
-
+ const char *ps_cause = switch_channel_get_variable(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE);
+
+ if (!switch_strlen_zero(ps_cause) && !strncasecmp(ps_cause, "sip:", 4)) {
+ int new_cause = atoi(ps_cause + 4);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Overriding SIP cause %d with %d from the other leg\n",
+ switch_channel_get_name(channel), sip_cause, new_cause);
+ sip_cause = new_cause;
+ }
if (switch_test_flag(tech_pvt, TFLAG_SIP_HOLD) && cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
const char *buuid;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu May 1 14:35:45 2008
@@ -2106,6 +2106,8 @@
}
switch_snprintf(st, sizeof(st), "%d", status);
switch_channel_set_variable(channel, "sip_term_status", st);
+ switch_snprintf(st, sizeof(st), "sip:%d", status);
+ switch_channel_set_variable_partner(channel, SWITCH_PROTO_SPECIFIC_HANGUP_CAUSE_VARIABLE, st);
switch_snprintf(st, sizeof(st), "%d", cause);
switch_channel_set_variable(channel, "sip_term_cause", st);
switch_channel_hangup(channel, cause);
1
0
Author: verifier
Date: Thu May 1 14:27:39 2008
New Revision: 8236
Added:
freeswitch/trunk/scripts/contrib/verifier/EventSocket/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Call.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallStateEvent.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/EventWatcher.csproj
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Extension.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.Designer.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.resx
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/LabelTextBox.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Program.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/AssemblyInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.Designer.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.resx
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.Designer.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.settings
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/ReadMePlease.txt
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/EventSocket.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/FreeSwitch.EventSocket.Test.csproj
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/ParserTest.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Program.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Properties/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Properties/AssemblyInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.sln
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/ChannelEvent.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelAnswer.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelApplication.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelBridge.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelCreate.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelDestroy.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOriginate.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOutgoing.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelProgress.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelState.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnbridge.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnpark.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventCodec.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmf.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmfStatus.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Api.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/HoldCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ParkCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/RecordCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SleepCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/TransferCmd.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.pfx (contents, props changed)
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventApiCommand.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventHeartbeat.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageQuery.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventReSchedule.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/Address.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/ChannelVariable.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SipAddress.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SofiaSipAddress.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PartyInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PlainEventMsg.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Program.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Properties/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Properties/AssemblyInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresence.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceProbe.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventRoster.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaExpire.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaRegister.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/SipEvent.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringHelper.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringParser.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/IvrSocket.csproj
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Properties/
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Properties/AssemblyInfo.cs
freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs
Log:
Initial version
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Call.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Call.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace EventWatcher
+{
+ public class Call
+ {
+ private CallState _currentState = CallState.Disconnected;
+ private CallState _previousState = CallState.Disconnected;
+ private string _id;
+ private string _destination;
+
+ public Call(string id)
+ {
+ _id = id;
+ }
+
+ public string Id
+ {
+ get { return _id; }
+ set { _id = value; }
+ }
+
+ public string Destination
+ {
+ get { return _destination; }
+ }
+
+ public CallState State
+ {
+ get { return _currentState; }
+ }
+
+ public CallState PreviousState
+ {
+ get { return _previousState; }
+ }
+
+ internal void SetCallState(CallState state)
+ {
+ _previousState = _currentState;
+ _currentState = state;
+ }
+
+ internal void SetDestination(string dest)
+ {
+ _destination = dest;
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallManager.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,251 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using FreeSwitch.EventSocket;
+using FreeSwitch.EventSocket.Commands;
+
+namespace EventWatcher
+{
+ internal class CallManager
+ {
+ #region Delegates
+
+ public delegate void CallStateHandler(CallManager mgr, CallStateEvent callEvent);
+
+ #endregion
+
+ private EventManager _eventMgr;
+ private IDictionary<string, CallStateEvent> _events = new Dictionary<string, CallStateEvent>();
+
+ private IDictionary<string, ExtensionMapper> _extensions = new Dictionary<string, ExtensionMapper>();
+ private int _lastCallId = 0;
+
+ public CallManager(EventManager eventSocket)
+ {
+ _eventMgr = eventSocket;
+ }
+
+ public event ExtensionHandler ExtensionAdded;
+ public event CallHandler ExtensionChanged;
+ public event ExtensionHandler ExtensionDisconnected;
+ public event CallStateHandler OnCallState;
+
+ private ExtensionMapper GetMapper(string address)
+ {
+ if (_extensions.ContainsKey(address))
+ return _extensions[address];
+ else
+ {
+ ExtensionMapper em = new ExtensionMapper();
+ em.setter = new ExtensionSetters();
+ em.extension = new Extension(address, em.setter);
+ _extensions.Add(address, em);
+ if (ExtensionAdded != null)
+ ExtensionAdded(em.extension);
+
+ return em;
+ }
+ }
+
+ private string ChannelDestination(string channelName)
+ {
+ //Check.Require(channelName, "Channel name must be set.");
+ string[] parts = channelName.Split('/');
+ //Check.Require(parts.Length == 3, "Channel must be sofia/<domain>/<user>");
+ return parts[2];
+ }
+
+ public void OnSwitchEvents(EventBase theEvent)
+ {
+ if (theEvent is EventPresenceIn)
+ {
+ EventPresenceIn ep = (EventPresenceIn) theEvent;
+ //Channel-State: CS_RING
+ //Channel-Name: sofia/default/jonas%40192.168.1.102%3A5070
+ //Unique-ID: 2f87ba27-2f71-d64d-8c64-9966ee894eac
+ //Call-Direction: inbound
+ //Answer-State: ringing
+ //Event-Name: PRESENCE_IN
+ CallState state = CallState.Unknown;
+ string destination = string.Empty;
+ if (ep.ChannelState.ChannelInfo.State == ChannelState.Ring)
+ {
+ if (IsInbound(ep))
+ {
+ state = CallState.Alerting;
+ destination = ep.Caller.DestinationNumber;
+ }
+ else
+ {
+ state = CallState.Offering;
+ destination = ep.Caller.UserName;
+ }
+ }
+ else if (ep.ChannelState.ChannelInfo.State == ChannelState.Hangup)
+ {
+ state = CallState.Disconnected;
+ if (IsInbound(ep))
+ destination = ep.Caller.DestinationNumber;
+ else
+ destination = ep.Caller.UserName;
+ }
+ if (state != CallState.Unknown)
+ TriggerCallState(ep.ChannelState.ChannelInfo.Address, ep.ChannelState.UniqueId, state, destination);
+ }
+ else if (theEvent is EventChannelAnswer)
+ {
+ EventChannelAnswer ea = (EventChannelAnswer) theEvent;
+ string destination;
+ if (IsInbound(ea))
+ destination = ea.Caller.DestinationNumber;
+ else
+ destination = ea.Caller.UserName;
+
+ TriggerCallState(ea.ChannelInfo.Address, ea.UniqueId, CallState.Connected, destination);
+ }
+
+ else if (theEvent is EventChannelDestroy)
+ {
+ EventChannelDestroy e = (EventChannelDestroy) theEvent;
+ Debug.WriteLine("triggering CallState.Disconnected");
+ TriggerCallState(e.ChannelInfo.Address, e.UniqueId, CallState.Disconnected,
+ e.Originator.DestinationNumber);
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="evt"></param>
+ /// <returns>true if it's inbound to pbx (not to user)</returns>
+ private bool IsInbound(EventBase evt)
+ {
+ return evt.Parameters["Call-Direction"] == "inbound";
+ }
+
+
+ public void OnSwitchEvents2(EventBase theEvent)
+ {
+ ChannelEvent evt = theEvent as ChannelEvent;
+ EventChannelState channelState = theEvent as EventChannelState;
+ if (channelState != null)
+ Debug.WriteLine("ChannelState: " + channelState.ChannelInfo.State + " " + channelState.Caller.UserName +
+ " " + channelState.Caller.DestinationNumber);
+ else if (evt != null && evt.ChannelInfo != null)
+ Debug.WriteLine("ChannelEvent: " + evt.Name + " " + evt.ChannelInfo.Address);
+ if (evt != null)
+ {
+ // CHANNEL_ANSWER, No originator = new outgoing call.
+ // ChannelName = the one who makes the call
+ if (evt is EventChannelAnswer)
+ {
+ EventChannelAnswer e = (EventChannelAnswer) evt;
+ if (e.Originator.CallerIdName != string.Empty)
+ {
+ Debug.WriteLine("Skipping emoty ChannelAnswer");
+ return; // We do only want empty ones.
+ }
+
+ if (!IsExternalNumber(evt.ChannelInfo.Address))
+ {
+ Debug.WriteLine("triggering CallState.Alerting");
+ TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Alerting,
+ e.Caller.DestinationNumber);
+ }
+ }
+
+ // CHANNEL_OUTGOING, Event for Alerting/Offering
+ // Originator = the one calling
+ // ChannelName = the one getting called.
+ else if (evt is EventChannelOutgoing)
+ {
+ EventChannelOutgoing e = (EventChannelOutgoing) evt;
+ if (!IsExternalNumber(evt.ChannelInfo.Address))
+ {
+ Debug.WriteLine("triggering CallState.Offering");
+ TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Offering, e.Originator.UserName);
+ }
+ if (!IsExternalNumber(e.Originator.UserName))
+ {
+ Debug.WriteLine("triggering CallState.Alerting");
+ TriggerCallState(e.Originator.UserName, e.Originator.UniqueId, CallState.Alerting,
+ e.ChannelInfo.Address);
+ }
+ }
+
+ else if (evt is EventChannelBridge)
+ {
+ EventChannelBridge e = (EventChannelBridge) evt;
+ if (!IsExternalNumber(evt.ChannelInfo.Address))
+ {
+ Debug.WriteLine("triggering CallState.Connected");
+ TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Connected,
+ e.Caller.DestinationNumber);
+ }
+
+ // Trigger destination
+ if (!IsExternalNumber(e.Caller.DestinationNumber) && e.Originator.ChannelName != string.Empty)
+ {
+ Debug.WriteLine("triggering CallState.Connected");
+ TriggerCallState(ChannelDestination(e.Originator.ChannelName), e.UniqueId, CallState.Connected,
+ e.ChannelInfo.Address);
+ }
+ }
+
+ else if (evt is EventChannelDestroy)
+ {
+ EventChannelDestroy e = (EventChannelDestroy) evt;
+ Debug.WriteLine("triggering CallState.Disconnected");
+ TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Disconnected,
+ e.Originator.DestinationNumber);
+ }
+ }
+ }
+
+ private bool IsExternalNumber(string number)
+ {
+ if (number == null || number == string.Empty)
+ return false;
+ return number[0] == '+';
+ }
+
+ private void TriggerCallState(string extensionOrUserName, string id, CallState state, string destination)
+ {
+ ExtensionMapper em = GetMapper(extensionOrUserName);
+ Debug.WriteLine(String.Format("{0} -> {1}, {2} id: {3}", extensionOrUserName, destination, state, id));
+ Call call = em.setter.callState(id, state, destination);
+ if (ExtensionChanged != null)
+ ExtensionChanged(em.extension, call);
+ }
+
+ private void OnBridgeCallId(CmdBase command, CommandReply reply)
+ {
+ GetVariableReply gvr = (GetVariableReply) reply;
+ if (!gvr.Success)
+ Debug.WriteLine("OnBridgeCallId " + reply.ErrCode);
+
+ string otherChannelId = (string) command.ContextData;
+ SetVariable sv = new SetVariable(otherChannelId, "gate_callid", gvr.Value);
+ sv.OnReply += OnCallIdReply;
+ _eventMgr.Send(sv);
+ command.OnReply -= OnBridgeCallId;
+ }
+
+ private void OnCallIdReply(CmdBase command, CommandReply reply)
+ {
+ if (!reply.Success)
+ Debug.WriteLine("OnCallIdReply " + reply.ErrCode);
+ command.OnReply -= OnCallIdReply;
+ }
+
+ #region Nested type: ExtensionMapper
+
+ private class ExtensionMapper
+ {
+ public Extension extension;
+ public ExtensionSetters setter;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallStateEvent.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/CallStateEvent.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,158 @@
+using System;
+
+namespace EventWatcher
+{
+ public enum CallState
+ {
+ Unknown,
+
+ /// <summary>
+ /// The call has been created, but Connect has not been called yet.
+ /// A call can never transition into the idle state.
+ /// This is the initial state for both incoming and outgoing calls.
+ /// </summary>
+ Idle,
+ /// <summary>
+ /// Connect has been called, and the service provider is working on
+ /// making a connection. This state is valid only on outgoing calls.
+ /// This message is optional, because a service provider may have a
+ /// call transition directly to the connected state.
+ /// </summary>
+ InProgress,
+ /// <summary>
+ /// Call has been connected to the remote end and communication can take place.
+ /// </summary>
+ Connected,
+ /// <summary>
+ /// Call has been disconnected. There are several causes for disconnection.
+ /// See the table of valid call state transitions below.
+ /// </summary>
+ Disconnected,
+ /// <summary>
+ /// A new call has appeared, and is being offered to an application.
+ /// If the application has owner privileges on the call, it can either
+ /// call Answer or Disconnect while the call is in the offering state.
+ /// </summary>
+ Offering,
+ Alerting,
+ /// <summary>
+ /// The call is in the hold state.
+ /// </summary>
+ Held,
+ }
+
+ public enum HangupCause
+ {
+ Success,
+ NormalClearing,
+ NoRouteTransitNet,
+ NoRouteDestination,
+ Busy,
+ Noanswer,
+ Rejected,
+ NumberChanged,
+ Congestion,
+ }
+ /// <summary>
+ /// Subclass for all call events.
+ /// The events are sent as commands through the
+ /// Command Dispatcher.
+ /// </summary>
+ [Serializable]
+ public class CallStateEvent
+ {
+ private string _callId;
+ private string _pbxId;
+ private string _destination;
+ private string _from;
+ private CallState _state = CallState.Idle;
+ private bool _isIncoming = true;
+ private bool _isInternal;
+ private HangupCause _hangupCause;
+
+ public CallStateEvent()
+ {
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="callId">Call identification string</param>
+ /// <param name="pbxId">Id used internally in the pbx to identify the call.</param>
+ /// <param name="from">Sip-Address to the one that made the call</param>
+ /// <param name="destination">Sip-address to where the call was made.</param>
+ public CallStateEvent(string callId, string pbxId, string from, string destination)
+ {
+ _callId = callId;
+ _from = from;
+ PbxId = pbxId;
+ _destination = destination;
+ }
+
+ /// <summary>
+ /// Call identification string.
+ /// </summary>
+ public string CallId
+ {
+ get { return _callId; }
+ set { _callId = value; }
+ }
+
+ /// <summary>
+ /// User that made the call.
+ /// </summary>
+ public string From
+ {
+ get { return _from; }
+ set { _from = value; }
+ }
+
+ /// <summary>
+ /// To whom the call was made.
+ /// </summary>
+ public string Destination
+ {
+ get { return _destination; }
+ set { _destination = value; }
+ }
+
+ /// <summary>
+ /// Current CallState.
+ /// </summary>
+ public CallState State
+ {
+ get { return _state; }
+ set { _state = value; }
+ }
+
+ /// <summary>
+ /// This is an incoming call.
+ /// </summary>
+ public bool Incoming
+ {
+ get { return _isIncoming; }
+ set { _isIncoming = value; }
+ }
+
+ /// <summary>
+ /// This is an internal call in the pbx.
+ /// </summary>
+ public bool Internal
+ {
+ get { return _isInternal; }
+ set { _isInternal = value; }
+ }
+
+ public HangupCause HangupCause
+ {
+ get { return _hangupCause; }
+ set { _hangupCause = value; }
+ }
+
+ internal string PbxId
+ {
+ get { return _pbxId; }
+ set { _pbxId = value; }
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/EventWatcher.csproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/EventWatcher.csproj Thu May 1 14:27:39 2008
@@ -0,0 +1,96 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{E65ABA5F-A578-4E3C-989D-0FE4E459C03D}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>EventWatcher</RootNamespace>
+ <AssemblyName>EventWatcher</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Design" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Call.cs" />
+ <Compile Include="CallManager.cs" />
+ <Compile Include="CallStateEvent.cs" />
+ <Compile Include="Extension.cs" />
+ <Compile Include="Form1.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="Form1.Designer.cs">
+ <DependentUpon>Form1.cs</DependentUpon>
+ </Compile>
+ <Compile Include="LabelTextBox.cs">
+ <SubType>Component</SubType>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Form1.resx">
+ <SubType>Designer</SubType>
+ <DependentUpon>Form1.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FreeSwitchEventSocket\FreeSwitch.EventSocket.csproj">
+ <Project>{3F8895F6-F710-4323-B96A-4EFB6BC97E08}</Project>
+ <Name>FreeSwitch.EventSocket</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="ReadMePlease.txt" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Extension.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Extension.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,162 @@
+using System;
+using System.Collections.Generic;
+
+namespace EventWatcher
+{
+ public delegate void ExtensionHandler(Extension extension);
+ public delegate void CallHandler(Extension extension, Call call);
+ public delegate Call CallStateSetter(string id, CallState state, string destination);
+
+ /// <summary>
+ /// Used to set states for the extension.
+ /// We are using this method since we do not want anything else
+ /// but the CallMgr to be able to set stuff.
+ /// </summary>
+ /// <param name="forwardAll">null if it has changed, else the new forward destination</param>
+ /// <param name="forwardBusy">null if it has changed, else the new forward destination</param>
+ /// <param name="forwardNoAnswer">null if it has changed, else the new forward destination</param>
+ public delegate void ForwardSetter(string forwardAll, string forwardBusy, string forwardNoAnswer);
+
+ public class ExtensionSetters
+ {
+ public CallStateSetter callState;
+ public ForwardSetter forwardSetter;
+ }
+
+ /// <summary>
+ /// Class representing an extension.
+ /// </summary>
+ [Serializable]
+ public class Extension
+ {
+ private readonly string _address = string.Empty;
+ private readonly IDictionary<string, Call> _calls = new Dictionary<string, Call>();
+ private readonly string _destination = string.Empty;
+ private string _forwardAll = string.Empty;
+ private string _forwardBusy = string.Empty;
+ private string _forwardNoAnswer = string.Empty;
+ private ExtensionSetters _handler;
+
+ public Extension(string address)
+ {
+ _address = address;
+ }
+
+ public Extension(string address, ExtensionSetters setters)
+ {
+ _address = address;
+ Handler = setters;
+ }
+
+ public bool IsBusy
+ {
+ get
+ {
+ foreach (KeyValuePair<string, Call> pair in _calls)
+ {
+ if (pair.Value.State != CallState.Disconnected
+ && pair.Value.State != CallState.Held)
+ return false;
+ }
+ return true;
+ }
+ }
+
+ /// <summary>
+ /// Determines if this extension is forwarded in any way
+ /// </summary>
+ public bool IsForwarded
+ {
+ get
+ {
+ return _forwardNoAnswer != string.Empty
+ || _forwardBusy != string.Empty
+ || _forwardAll != string.Empty;
+ }
+ }
+
+ public string ForwardAll
+ {
+ get { return _forwardAll; }
+ }
+
+ public string ForwardBusy
+ {
+ get { return _forwardBusy; }
+ }
+
+ public string ForwardNoAnswer
+ {
+ get { return _forwardNoAnswer; }
+ }
+
+ public string Destination
+ {
+ get { return _destination; }
+ }
+
+ public string Address
+ {
+ get { return _address; }
+ }
+
+ public ExtensionSetters Handler
+ {
+ get { return _handler; }
+ set
+ {
+ if (value != null)
+ //Check.Require(_handler == null, "Handler can only be assigned one time.");
+
+ _handler = value;
+ if (value != null)
+ {
+ value.callState = SetCallState;
+ value.forwardSetter = SetForward;
+ }
+ }
+ }
+
+ private Call SetCallState(string id, CallState state, string destination)
+ {
+ bool wasBusy = IsBusy;
+
+ Call call;
+ if (!_calls.ContainsKey(id))
+ call = new Call(id);
+ else
+ call = _calls[id];
+
+ call.SetCallState(state);
+ call.SetDestination(destination);
+
+ if (CallChanged != null)
+ CallChanged(this, call);
+
+ if (state == CallState.Disconnected)
+ _calls.Remove(id);
+
+
+ if (wasBusy != IsBusy && BusyStateChanged != null)
+ BusyStateChanged(this);
+
+ return call;
+ }
+
+ private void SetForward(string forwardAll, string forwardBusy, string forwardNoAnswer)
+ {
+ if (forwardAll != null)
+ _forwardAll = forwardAll;
+ if (forwardBusy != null)
+ _forwardBusy = forwardBusy;
+ if (forwardNoAnswer != null)
+ _forwardNoAnswer = forwardNoAnswer;
+ if (ForwardChanged != null)
+ ForwardChanged(this);
+ }
+
+ public event ExtensionHandler BusyStateChanged;
+ public event CallHandler CallChanged;
+ public event ExtensionHandler ForwardChanged;
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.Designer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.Designer.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,212 @@
+namespace EventWatcher
+{
+ partial class Form1
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.panel1 = new System.Windows.Forms.Panel();
+ this.log = new System.Windows.Forms.TextBox();
+ this.info = new System.Windows.Forms.RichTextBox();
+ this.lv = new System.Windows.Forms.ListView();
+ this.colAddress = new System.Windows.Forms.ColumnHeader();
+ this.colId = new System.Windows.Forms.ColumnHeader();
+ this.colPbxId = new System.Windows.Forms.ColumnHeader();
+ this.colState = new System.Windows.Forms.ColumnHeader();
+ this.colCaller = new System.Windows.Forms.ColumnHeader();
+ this.colOriginator = new System.Windows.Forms.ColumnHeader();
+ this.colOrginatee = new System.Windows.Forms.ColumnHeader();
+ this.lvAll = new System.Windows.Forms.ListView();
+ this.from = new System.Windows.Forms.ColumnHeader();
+ this.To = new System.Windows.Forms.ColumnHeader();
+ this.ChannelId = new System.Windows.Forms.ColumnHeader();
+ this.SessionId = new System.Windows.Forms.ColumnHeader();
+ this.State = new System.Windows.Forms.ColumnHeader();
+ this.panel1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel1
+ //
+ this.panel1.Controls.Add(this.log);
+ this.panel1.Controls.Add(this.info);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
+ this.panel1.Location = new System.Drawing.Point(627, 0);
+ this.panel1.Name = "panel1";
+ this.panel1.Size = new System.Drawing.Size(293, 546);
+ this.panel1.TabIndex = 11;
+ //
+ // log
+ //
+ this.log.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.log.Location = new System.Drawing.Point(0, 526);
+ this.log.Name = "log";
+ this.log.Size = new System.Drawing.Size(293, 20);
+ this.log.TabIndex = 11;
+ //
+ // info
+ //
+ this.info.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.info.Location = new System.Drawing.Point(0, 0);
+ this.info.Name = "info";
+ this.info.Size = new System.Drawing.Size(293, 546);
+ this.info.TabIndex = 10;
+ this.info.Text = "";
+ //
+ // lv
+ //
+ this.lv.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.colAddress,
+ this.colId,
+ this.colPbxId,
+ this.colState,
+ this.colCaller,
+ this.colOriginator,
+ this.colOrginatee});
+ this.lv.Dock = System.Windows.Forms.DockStyle.Top;
+ this.lv.Location = new System.Drawing.Point(0, 0);
+ this.lv.Name = "lv";
+ this.lv.Size = new System.Drawing.Size(627, 152);
+ this.lv.TabIndex = 12;
+ this.lv.UseCompatibleStateImageBehavior = false;
+ this.lv.View = System.Windows.Forms.View.Details;
+ //
+ // colAddress
+ //
+ this.colAddress.Text = "Anknytning";
+ this.colAddress.Width = 65;
+ //
+ // colId
+ //
+ this.colId.Text = "Id";
+ this.colId.Width = 26;
+ //
+ // colPbxId
+ //
+ this.colPbxId.Text = "PbxId";
+ this.colPbxId.Width = 230;
+ //
+ // colState
+ //
+ this.colState.Text = "Status";
+ this.colState.Width = 50;
+ //
+ // colCaller
+ //
+ this.colCaller.Text = "Caller";
+ this.colCaller.Width = 62;
+ //
+ // colOriginator
+ //
+ this.colOriginator.Text = "Originator";
+ this.colOriginator.Width = 72;
+ //
+ // colOrginatee
+ //
+ this.colOrginatee.Text = "Orginatee";
+ this.colOrginatee.Width = 116;
+ //
+ // lvAll
+ //
+ this.lvAll.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.from,
+ this.To,
+ this.ChannelId,
+ this.SessionId,
+ this.State});
+ this.lvAll.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.lvAll.Location = new System.Drawing.Point(0, 152);
+ this.lvAll.Name = "lvAll";
+ this.lvAll.Size = new System.Drawing.Size(627, 394);
+ this.lvAll.TabIndex = 13;
+ this.lvAll.UseCompatibleStateImageBehavior = false;
+ this.lvAll.View = System.Windows.Forms.View.Details;
+ this.lvAll.SelectedIndexChanged += new System.EventHandler(this.lvAll_SelectedIndexChanged);
+ this.lvAll.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.lvAll_ItemSelectionChanged);
+ //
+ // from
+ //
+ this.from.Text = "Fr�n";
+ //
+ // To
+ //
+ this.To.Text = "Till";
+ this.To.Width = 84;
+ //
+ // ChannelId
+ //
+ this.ChannelId.Text = "ChannelId";
+ this.ChannelId.Width = 282;
+ //
+ // SessionId
+ //
+ this.SessionId.Text = "SessionId";
+ this.SessionId.Width = 318;
+ //
+ // State
+ //
+ this.State.Text = "State";
+ this.State.Width = 99;
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(920, 546);
+ this.Controls.Add(this.lvAll);
+ this.Controls.Add(this.lv);
+ this.Controls.Add(this.panel1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ this.panel1.ResumeLayout(false);
+ this.panel1.PerformLayout();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Panel panel1;
+ private System.Windows.Forms.TextBox log;
+ private System.Windows.Forms.RichTextBox info;
+ private System.Windows.Forms.ListView lv;
+ private System.Windows.Forms.ColumnHeader colAddress;
+ private System.Windows.Forms.ColumnHeader colId;
+ private System.Windows.Forms.ColumnHeader colPbxId;
+ private System.Windows.Forms.ColumnHeader colState;
+ private System.Windows.Forms.ColumnHeader colCaller;
+ private System.Windows.Forms.ColumnHeader colOriginator;
+ private System.Windows.Forms.ColumnHeader colOrginatee;
+ private System.Windows.Forms.ListView lvAll;
+ private System.Windows.Forms.ColumnHeader from;
+ private System.Windows.Forms.ColumnHeader To;
+ private System.Windows.Forms.ColumnHeader ChannelId;
+ private System.Windows.Forms.ColumnHeader SessionId;
+ private System.Windows.Forms.ColumnHeader State;
+
+ }
+}
+
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,235 @@
+using System;
+using System.Diagnostics;
+using System.Drawing;
+using System.Reflection;
+using System.Windows.Forms;
+using FreeSwitch.EventSocket;
+using FreeSwitch.EventSocket.Commands;
+using FreeSwitch.EventSocket.General;
+
+namespace EventWatcher
+{
+ public partial class Form1 : Form
+ {
+ private EventManager _eventMgr;
+ private CallManager _callMgr;
+
+ public Form1()
+ {
+ InitializeComponent();
+ _eventMgr = new EventManager();
+ _callMgr = new CallManager(_eventMgr);
+ _callMgr.OnCallState += OnCallState;
+ _callMgr.ExtensionAdded += OnExtensionAdded;
+ _callMgr.ExtensionChanged += OnExtensionChanged;
+
+
+ }
+
+ private void OnExtensionAdded(Extension extension)
+ {
+ //throw new NotImplementedException();
+ }
+
+ private void OnExtensionChanged(Extension extension, Call call)
+ {
+ if (lv.InvokeRequired)
+ BeginInvoke((MethodInvoker)delegate { OnExtensionChangedX(extension, call); });
+ else
+ OnExtensionChangedX(extension, call);
+ }
+
+ private void OnExtensionChangedX(Extension extension, Call call)
+ {
+ ListViewItem item = null;
+ foreach (ListViewItem item2 in lv.Items)
+ {
+ if (String.Compare(item2.Name, extension.Address, true) == 0)
+ {
+ item = item2;
+ break;
+ }
+ }
+ if (item == null)//(!lv.Items.ContainsKey(extension.Address))
+ {
+ item = lv.Items.Add(extension.Address, extension.Address, 0);
+ item.Tag = extension;
+ item.SubItems.Add(call.Id);
+ item.SubItems.Add(call.State.ToString());
+ item.SubItems.Add(call.PreviousState.ToString());
+ item.SubItems.Add("");
+ item.SubItems.Add(extension.Destination);
+ }
+ else
+ {
+ item.SubItems[2].Text = call.State.ToString();
+ item.SubItems[3].Text = call.PreviousState.ToString();
+ }
+ }
+
+ private void OnExtensionCallState(Extension e)
+ {
+
+ }
+ private void OnCallState(CallManager mgr, CallStateEvent cs)
+ {
+ if (lv.InvokeRequired)
+ BeginInvoke((MethodInvoker)delegate { OnCallStateX(mgr, cs); });
+ else
+ OnCallStateX(mgr, cs);
+ }
+
+ private void OnCallStateX(CallManager mgr, CallStateEvent cs)
+ {
+ ListViewItem item;
+ if (!lv.Items.ContainsKey(cs.PbxId))
+ {
+ item = lv.Items.Add(cs.PbxId, cs.From, 0);
+ item.Tag = cs;
+ item.SubItems.Add(cs.CallId);
+ item.SubItems.Add(cs.PbxId);
+ item.SubItems.Add(cs.State.ToString());
+ item.SubItems.Add(cs.From);
+ item.SubItems.Add(cs.Destination);
+ }
+ else
+ item = lv.Items[cs.PbxId];
+
+ item.SubItems[1].Text = cs.CallId;
+ item.SubItems[3].Text = cs.State.ToString();
+ item.SubItems[4].Text = cs.Destination;
+
+ if (cs.State == CallState.Disconnected)
+ lv.Items.RemoveByKey(cs.PbxId);
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ _eventMgr.Password = "ClueCon";
+ _eventMgr.Start("localhost");
+ _eventMgr.Subscribe(new Events(Event.All));
+ _eventMgr.EventReceived += OnPreSwitchEvent;
+ }
+
+ private void OnPreSwitchEvent(EventBase theEvent)
+ {
+ _callMgr.OnSwitchEvents(theEvent);
+ if (lvAll.InvokeRequired)
+ BeginInvoke((MethodInvoker)delegate { OnSwitchEvent(theEvent); });
+ else
+ OnSwitchEvent(theEvent);
+ }
+
+
+ private string DisplayProperties(object o)
+ {
+ return DisplayProperties(o, 0);
+ }
+
+ private string DisplayProperties(object o, int spaces)
+ {
+ PropertyInfo[] pis = o.GetType().GetProperties();
+ string info = string.Empty;
+ foreach (PropertyInfo pi in pis)
+ {
+ if (pi.PropertyType == typeof (ChannelInfo) || pi.PropertyType == typeof (PartyInfo))
+ {
+ info += pi.Name.PadLeft(spaces + pi.Name.Length) + "\r\n";
+ info += DisplayProperties(pi.GetValue(o, null), spaces + 2);
+ }
+ else
+ info += pi.Name.PadLeft(spaces + pi.Name.Length) + ": " + pi.GetValue(o, null) + "\r\n";
+ }
+ return info;
+ }
+
+ private void OnSwitchEvent(EventBase theEvent)
+ {
+ EventChannelState e = theEvent as EventChannelState;
+ if (e != null)
+ {
+
+ EventChannelState channelEvent = theEvent as EventChannelState;
+ if (channelEvent == null)
+ return;
+
+ //OnSwitchEvents(theEvent);
+
+ ListViewItem item;
+ item = lvAll.Items.Add(channelEvent.ChannelInfo.Address);
+ item.Tag = channelEvent;
+ item.SubItems.Add(channelEvent.Originator.UserName);
+ item.SubItems.Add(channelEvent.UniqueId);
+ item.SubItems.Add(channelEvent.Caller.UniqueId);
+ if (channelEvent.Name == "CHANNEL_STATE")
+ item.SubItems.Add(e.ChannelInfo.State.ToString());
+ else
+ item.SubItems.Add(e.Name);
+
+ if (e.GetType() == typeof(EventCodec) || theEvent.GetType() == typeof(EventChannelExecute)
+ || e.Originator.DestinationNumber == string.Empty)
+ {
+ item.ForeColor = Color.Gray;
+ }
+
+ }
+ log.Text = theEvent.Name;
+ }
+
+ private void AddEvent(ListBox box, ChannelEvent e)
+ {
+ box.Items.Insert(0, new Wrapper(e));
+ }
+
+ private void lvAll_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ /*
+ if (lvAll.SelectedItems.Count == 0)
+ return;
+ ListViewItem itm = lvAll.SelectedItems[0];
+ MessageBox.Show(DisplayProperties(itm.Tag));
+ * */
+ }
+
+ private void lvAll_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
+ {
+ if (lvAll.SelectedItems.Count == 0)
+ return;
+ ListViewItem itm = lvAll.SelectedItems[0];
+ info.Text = DisplayProperties(itm.Tag);
+ }
+
+ #region Nested type: SwitchEventHandler
+
+ private delegate void SwitchEventHandler(EventBase theEvent);
+
+ #endregion
+
+ #region Nested type: Wrapper
+
+ private class Wrapper
+ {
+ public ChannelEvent e;
+
+ public Wrapper(ChannelEvent e)
+ {
+ this.e = e;
+ }
+
+ public override string ToString()
+ {
+ return "[" + e.Name + "] " + e.ChannelInfo.State;
+ }
+ }
+
+ #endregion
+
+ private void btnOriginate_Click(object sender, EventArgs e)
+ {
+ //Originate org = new Originate();
+ //org.Caller = new SofiaSipAddress("gauffin.com");
+ //from_id.Text
+ }
+
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.resx
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Form1.resx Thu May 1 14:27:39 2008
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/LabelTextBox.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/LabelTextBox.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace EventWatcher
+{
+ class LabelTextBox : TextBox
+ {
+ private string _label;
+
+ public string Label
+ {
+ get { return _label; }
+ set
+ {
+ _label = value;
+ if (Text == string.Empty)
+ SetLabel();
+ }
+ }
+
+ public void test()
+ {
+ TextBox x = new TextBox();
+ x.KeyDown += tb_KeyDown;
+ x.TextChanged += tb_TextChanged;
+ }
+
+ private void tb_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
+ {
+ if (ForeColor == Color.FromKnownColor(KnownColor.InactiveCaptionText))
+ RemoveLabel();
+ }
+
+ private void tb_TextChanged(object sender, EventArgs e)
+ {
+ if (Text == string.Empty)
+ SetLabel();
+ else if (Text != _label && Text != string.Empty)
+ RemoveLabel();
+ }
+
+ private void RemoveLabel()
+ {
+ ForeColor = Color.FromKnownColor(KnownColor.WindowText);
+ Text = string.Empty;
+
+ }
+ private void SetLabel()
+ {
+ ForeColor = Color.FromKnownColor(KnownColor.InactiveCaptionText);
+ Text = _label;
+
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Program.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Program.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+namespace EventWatcher
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/AssemblyInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("EventWatcher")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("EventWatcher")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("e6a71f21-6833-455f-a398-a0d6a54c1359")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.Designer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.Designer.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.312
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EventWatcher.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EventWatcher.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.resx
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Resources.resx Thu May 1 14:27:39 2008
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.Designer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.Designer.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:2.0.50727.312
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace EventWatcher.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.settings
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/Properties/Settings.settings Thu May 1 14:27:39 2008
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/ReadMePlease.txt
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/EventWatcher/ReadMePlease.txt Thu May 1 14:27:39 2008
@@ -0,0 +1,3 @@
+This is just a test project that I used to develop the event socket lib.
+
+It could in the future be an application that keep track on all channels and their current state.
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/EventSocket.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/EventSocket.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using FreeSwitch.EventSocket;
+using FreeSwitch.EventSocket.Commands;
+using FreeSwitch.EventSocket.General;
+
+namespace FreeSwitch.EventSocket.Test
+{
+ class EventSocket
+ {
+ private FreeSwitch.EventSocket.EventSocket m_es = new FreeSwitch.EventSocket.EventSocket();
+
+ public void Setup()
+ {
+ m_es.Connect("192.168.1.102");
+ m_es.Subscribe(new Events(Event.All));
+ //m_es.SendApi(new Originate(new SofiaSipAddress("gauffin.com", "arne"), new Address("8888")));
+ System.Threading.Thread.Sleep(500000);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/FreeSwitch.EventSocket.Test.csproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/FreeSwitch.EventSocket.Test.csproj Thu May 1 14:27:39 2008
@@ -0,0 +1,55 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3679225D-79A3-4B6C-BCA1-E2DC265E423A}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FreeSwitch.EventSocket.Test</RootNamespace>
+ <AssemblyName>FreeSwitch.EventSocket.Test</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="EventSocket.cs" />
+ <Compile Include="ParserTest.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FreeSwitchEventSocket\FreeSwitch.EventSocket.csproj">
+ <Project>{3F8895F6-F710-4323-B96A-4EFB6BC97E08}</Project>
+ <Name>FreeSwitch.EventSocket</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/ParserTest.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/ParserTest.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.Test
+{
+ class ParserTest
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Program.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Program.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.Test
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ EventManager mgr = new EventManager();
+ mgr.Subscribe(Events.GetChannelEvents());
+ mgr.Start("localhost");
+ Console.ReadLine();
+
+ string buffer = File.ReadAllText("..\\..\\..\\watcherRaw.log");
+ int bufLen = buffer.Length;
+
+ EventParser ep = new EventParser(buffer);
+ //int cnt = 0;
+ EventSocket es = new EventSocket();
+ es.Setup();
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.Test/Properties/AssemblyInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FreeSwitch.EventSocket.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FreeSwitch.EventSocket.Test")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b496f9be-f1be-457d-b8c8-fae97c43df8e")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.sln
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitch.EventSocket.sln Thu May 1 14:27:39 2008
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSwitch.EventSocket", "FreeSwitchEventSocket\FreeSwitch.EventSocket.csproj", "{3F8895F6-F710-4323-B96A-4EFB6BC97E08}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FreeSwitch.EventSocket.Test", "FreeSwitch.EventSocket.Test\FreeSwitch.EventSocket.Test.csproj", "{3679225D-79A3-4B6C-BCA1-E2DC265E423A}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventWatcher", "EventWatcher\EventWatcher.csproj", "{E65ABA5F-A578-4E3C-989D-0FE4E459C03D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IvrSocket", "IvrSocket\IvrSocket.csproj", "{22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {3F8895F6-F710-4323-B96A-4EFB6BC97E08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3F8895F6-F710-4323-B96A-4EFB6BC97E08}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3F8895F6-F710-4323-B96A-4EFB6BC97E08}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3F8895F6-F710-4323-B96A-4EFB6BC97E08}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3679225D-79A3-4B6C-BCA1-E2DC265E423A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3679225D-79A3-4B6C-BCA1-E2DC265E423A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3679225D-79A3-4B6C-BCA1-E2DC265E423A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3679225D-79A3-4B6C-BCA1-E2DC265E423A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E65ABA5F-A578-4E3C-989D-0FE4E459C03D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E65ABA5F-A578-4E3C-989D-0FE4E459C03D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E65ABA5F-A578-4E3C-989D-0FE4E459C03D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E65ABA5F-A578-4E3C-989D-0FE4E459C03D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/ChannelEvent.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/ChannelEvent.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class ChannelEvent : EventBase
+ {
+ private ChannelInfo _channelInfo;
+ private string _uniqueId = string.Empty;
+ private string _answerState;
+ private string _callDirection;
+
+ public override bool IsChannelEvent
+ {
+ get { return true; }
+ }
+
+ /// <summary>
+ /// Information about the used channel and it's state.
+ /// </summary>
+ public ChannelInfo ChannelInfo
+ {
+ get { return _channelInfo; }
+ set { _channelInfo = value; }
+ }
+
+ public string UniqueId
+ {
+ get { return _uniqueId; }
+ set { _uniqueId = value; }
+ }
+
+ public string AnswerState
+ {
+ get { return _answerState; }
+ set { _answerState = value; }
+ }
+
+ public string CallDirection
+ {
+ get { return _callDirection; }
+ set { _callDirection = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "unique-id")
+ _uniqueId = value;
+ else if (name == "answer-state")
+ _answerState = value;
+ else if (name == "call-direction")
+ _callDirection = value;
+ else if (name.Length > 8 && name.Substring(0, 8) == "channel-")
+ {
+ if (_channelInfo == null)
+ _channelInfo = new ChannelInfo();
+ return _channelInfo.Parse(name, value);
+ }
+ else
+ return base.ParseCommand(name, value);
+
+ return true;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelAnswer.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelAnswer.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,6 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelAnswer : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelApplication.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelApplication.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelApplication : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelBridge.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelBridge.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelBridge : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelCreate.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelCreate.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,6 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelCreate : ChannelEvent
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelDestroy.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelDestroy.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelDestroy : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecute.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelExecute : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelExecuteComplete.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,7 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelExecuteComplete : EventChannelState
+ {
+ }
+}
+
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelHangup.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelHangup : EventChannelState
+ {
+ private Causes m_hangupCause;
+
+ public enum Causes
+ {
+ Success,
+ NoRouteTransitNet,
+ NoRouteDestination,
+ ChannelUnacceptable,
+ CallAwardedDelivered,
+ NormalClearing,
+ UserBusy,
+ NoUserResponse,
+ NoAnswer,
+ SubscriberAbsent,
+ CallRejected,
+ NumberChanged,
+ RedirectionToNewDestination,
+ ExchangeRoutingError,
+ DestinationOutOfOrder,
+ InvalidNumberFormat,
+ FacilityRejected,
+ ResponseToStatusEnquiry,
+ NormalUnspecified,
+ NormalCircuitCongestion,
+ NetworkOutOfOrder,
+ NormalTemporaryFailure,
+ SwitchCongestion,
+ AccessInfoDiscarded,
+ RequestedChanUnavail,
+ PreEmpted,
+ FacilityNotSubscribed,
+ OutgoingCallBarred,
+ IncomingCallBarred,
+ BearercapabilityNotauth,
+ BearercapabilityNotavail,
+ ServiceUnavailable,
+ ChanNotImplemented,
+ FacilityNotImplemented,
+ ServiceNotImplemented,
+ InvalidCallReference,
+ IncompatibleDestination,
+ InvalidMsgUnspecified,
+ MandatoryIeMissing,
+ MessageTypeNonexist,
+ WrongMessage,
+ IeNonexist,
+ InvalidIeContents,
+ WrongCallState,
+ RecoveryOnTimerExpire,
+ MandatoryIeLengthError,
+ ProtocolError,
+ Interworking,
+ OriginatorCancel,
+ Crash,
+ SystemShutdown,
+ LoseRace,
+ ManagerRequest,
+ BlindTransfer,
+ AttendedTransfer,
+ AllottedTimeout
+ }
+
+ public Causes Cause
+ {
+ get { return m_hangupCause; }
+ set { m_hangupCause = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "hangupcause" || name == "hangup-cause")
+ {
+ string cause = StringHelper.UpperCaseToCamelCase(value);
+ m_hangupCause = (Causes)Enum.Parse(typeof(Causes), cause);
+ }
+ else
+ return base.ParseCommand(name, value);
+
+ return true;
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOriginate.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOriginate.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelOriginate : ChannelEvent
+ {
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOutgoing.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelOutgoing.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelOutgoing : EventChannelState
+ {
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelProgress.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelProgress.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelProgress : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelState.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelState.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,63 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelState : ChannelEvent
+ {
+ private PartyInfo _caller = new PartyInfo();
+ private PartyInfo _originator = new PartyInfo();
+ private bool _screenBit = false;
+
+ /// <summary>
+ /// Information about the called party.
+ /// This property is null for certain channel states,
+ /// depending on if freeswitch sends it or not.
+ /// </summary>
+ public PartyInfo Caller
+ {
+ get { return _caller; }
+ set { _caller = value; }
+ }
+
+ /// <summary>
+ /// Information about the destination (place that the caller want to reach).
+ /// This property is null for certain channel states,
+ /// depending on if freeswitch sends it or not.
+ /// </summary>
+ public PartyInfo Originator
+ {
+ get { return _originator; }
+ set { _originator = value; }
+ }
+
+ public bool ScreenBit
+ {
+ get { return _screenBit; }
+ set { _screenBit = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "screen-bit")
+ {
+ ScreenBit = value == "yes";
+ return true;
+ }
+ else if (name.Length > 11 && name.Substring(0, 11) == "originator-"
+ || name.Length > 11 && name.Substring(0, 11) == "originatee-")
+ {
+ if (_originator == null)
+ _originator = new PartyInfo();
+
+ return _originator.Parse(name.Substring(11), value);
+ }
+ else if (name.Length > 7 && name.Substring(0, 7) == "caller-")
+ {
+ if (_caller == null)
+ _caller = new PartyInfo();
+
+ return _caller.Parse(name.Substring(7), value);
+ }
+ else
+ return base.ParseCommand(name, value);
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnbridge.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnbridge.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelUnbridge : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnpark.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventChannelUnpark.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventChannelUnpark : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventCodec.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventCodec.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,6 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventCodec : EventChannelState
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmf.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmf.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,35 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventDtmf : ChannelEvent
+ {
+ private char _digit;
+ private int _duration;
+
+ public char Digit
+ {
+ get { return _digit; }
+ set { _digit = value; }
+ }
+
+ public int Duration
+ {
+ get { return _duration; }
+ set { _duration = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch(name)
+ {
+ case "dtmf-digit":
+ _digit = value[0];
+ break;
+ case "dtmf-duration":
+ int.TryParse(value, out _duration);
+ break;
+ }
+
+ return base.ParseCommand(name, value);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmfStatus.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelEvents/EventDtmfStatus.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,31 @@
+namespace FreeSwitch.EventSocket
+{
+ /// <summary>
+ /// Reports when DTMF digits have been pressed
+ /// </summary>
+ public class EventDtmfStatus : ChannelEvent
+ {
+ private int _count;
+
+ /// <summary>
+ /// Number of digits in the buffer.
+ /// </summary>
+ public int Count
+ {
+ get { return _count; }
+ }
+
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "dtmf-count":
+ int.TryParse(value, out _count);
+ break;
+ }
+
+ return base.ParseCommand(name, value);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/ChannelInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,225 @@
+namespace FreeSwitch.EventSocket
+{
+ #region enum ChannelState
+ public enum ChannelState
+ {
+ New, // Channel is newly created
+ Init, // Channel has been initilized
+ Ring, // Channel is looking for a dialplan
+ Transmit, // Channel is in a passive transmit state
+ Execute, // Channel is executing it's dialplan
+ Loopback, // Channel is in loopback
+ Hold, // Channel is on hold
+ Hibernate, // Channel is in a sleep state
+ Hangup, // Channel is flagged for hangup and ready to end
+ Done, // Channel is ready to be destroyed and out of the state machine
+ Unknown
+ }
+ #endregion
+
+ public class ChannelInfo
+ {
+ private ChannelState m_state;
+ private int m_stateNumber;
+ private string _profile;
+ private string m_address;
+ private string _hostName;
+ private string m_protocol = string.Empty;
+ private string m_readCodecName;
+ private int m_readCodecRate;
+ private string m_writeCodecName;
+ private int m_writeCodecRate;
+
+ /// <summary>
+ /// Coded used to read information from the channel.
+ /// Example: L16
+ /// </summary>
+ public string ReadCodecName
+ {
+ get { return m_readCodecName; }
+ set { m_readCodecName = value; }
+ }
+
+ /// <summary>
+ /// Bitrate of the read coded that is used.
+ /// Example: 8000
+ /// </summary>
+ public int ReadCodecRate
+ {
+ get { return m_readCodecRate; }
+ set { m_readCodecRate = value; }
+ }
+
+ /// <summary>
+ /// Codec used for writing to the channel.
+ /// Example: L16
+ /// </summary>
+ public string WriteCodecName
+ {
+ get { return m_writeCodecName; }
+ set { m_writeCodecName = value; }
+ }
+
+ /// <summary>
+ /// Bitrate of the codec.
+ /// Example: 8000
+ /// </summary>
+ public int WriteCodecRate
+ {
+ get { return m_writeCodecRate; }
+ set { m_writeCodecRate = value; }
+ }
+
+ /// <summary>
+ /// State that the channel is in. Check ChannelState enum for more information.
+ /// </summary>
+ public ChannelState State
+ {
+ get { return m_state; }
+ set { m_state = value; }
+ }
+
+ /// <summary>
+ /// Number of the state (from the enum in FreeSwitch)
+ /// </summary>
+ public int StateNumber
+ {
+ get { return m_stateNumber; }
+ set { m_stateNumber = value; }
+ }
+
+ /// <summary>
+ /// Name of the channel.
+ /// </summary>
+ /// <example>sofia/mydomain.com/1234@conference.freeswitch.org</example>
+ /// <seealso cref="ChannelInfo.Protocol"/>
+ /// <seealso cref="ProfileName"/>
+ /// <seealso cref="Address"/>
+ /// <seealso cref="HostName"/>
+ public string Name
+ {
+ get { return m_protocol + "/" + _profile + "/" + m_address + "@" + _hostName; }
+ set
+ {
+ string[] bits = value.Split('/');
+ if (bits.Length == 3)
+ {
+ m_protocol = bits[0];
+ _profile = bits[1];
+ string[] userParts = bits[2].Split('@');
+ if (userParts.Length == 2)
+ {
+ m_address = userParts[0];
+ HostName = userParts[1];
+ }
+ else
+ m_address = bits[2];
+ }
+
+ }
+ }
+
+ /// <summary>
+ /// ProfileName for the diaplan/sip.
+ /// </summary>
+ public string ProfileName
+ {
+ get { return _profile; }
+ set { _profile = value; }
+ }
+
+ /// <summary>
+ /// Extension/Username for the channel
+ /// </summary>
+ public string Address
+ {
+ get { return m_address; }
+ set { m_address = value; }
+ }
+
+ /// <summary>
+ /// Where the extension/user is calling from.
+ /// </summary>
+ public string HostName
+ {
+ get { return _hostName; }
+ set
+ {
+ if (value == null)
+ {
+ _hostName = string.Empty;
+ return;
+ }
+
+ int pos = value.IndexOf(':');
+ if (pos == -1)
+ _hostName = value;
+ else
+ _hostName = value.Substring(0, pos);
+ }
+ }
+
+ /// <summary>
+ /// Protocol used for communication.
+ /// "sofia" = sip.
+ /// </summary>
+ public string Protocol
+ {
+ get { return m_protocol; }
+ }
+
+ public bool Parse(string name, string value)
+ {
+ switch (name)
+ {
+ case "channel-state":
+ m_state = StateFromString(value);
+ break;
+ case "channel-state-number":
+ int.TryParse(value, out m_stateNumber);
+ break;
+ case "channel-name":
+ Name = value;
+ break;
+ case "channel-read-codec-name":
+ m_readCodecName = value;
+ break;
+ case "channel-read-codec-rate":
+ int.TryParse(value, out m_readCodecRate);
+ break;
+ case "channel-write-codec-name":
+ m_writeCodecName = value;
+ break;
+ case "channel-write-codec-rate":
+ int.TryParse(value, out m_writeCodecRate);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+
+ public ChannelState StateFromString(string state)
+ {
+ switch (state)
+ {
+ case "CS_NEW": return ChannelState.New;
+ case "CS_INIT": return ChannelState.Init;
+ case "CS_RING": return ChannelState.Ring;
+ case "CS_TRANSMIT": return ChannelState.Transmit;
+ case "CS_EXECUTE": return ChannelState.Execute;
+ case "CS_LOOPBACK": return ChannelState.Loopback;
+ case "CS_HOLD": return ChannelState.Hold;
+ case "CS_HIBERNATE": return ChannelState.Hibernate;
+ case "CS_HANGUP": return ChannelState.Hangup;
+ case "CS_DONE": return ChannelState.Done;
+ default: return ChannelState.Unknown;
+ }
+ }
+
+ public string StateToString(ChannelState state)
+ {
+ return "Unknown";
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AnyCommand.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,36 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class AnyCommand : Api
+ {
+ private readonly string _name;
+ private readonly string _value;
+
+ public AnyCommand(string name, string arguments)
+ {
+ _name = name;
+ _value = arguments;
+ }
+
+ public override string Command
+ {
+ get { return _name; }
+ }
+
+ public override string Arguments
+ {
+ get { return _value; }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse.Length > 0 && (dataToParse[0] == '+') || dataToParse == "OK")
+ return new CommandReply(true);
+ else
+ {
+ CommandReply reply = new CommandReply(false);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Api.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Api.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public abstract class Api : CmdBase
+ {
+ public override string ToString()
+ {
+ return string.Format("api {0} {1}", Command, Arguments);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/AuthCommand.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,34 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class AuthCommand : CmdBase
+ {
+ private readonly string _password;
+
+ public AuthCommand(string password)
+ {
+ _password = password;
+ }
+
+ public override string Command
+ {
+ get { return "auth"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _password; }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse.Contains("+OK"))
+ return new CommandReply(true);
+ else
+ {
+ CommandReply reply = new CommandReply(false);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CmdBase.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,55 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ #region Delegates
+
+ public delegate void ReplyHandler(CmdBase command, CommandReply reply);
+
+ #endregion
+
+ public abstract class CmdBase
+ {
+ public event ReplyHandler OnReply;
+
+ private object _contextData;
+
+ public abstract string Command
+ {
+ get;
+ }
+
+ public abstract string Arguments
+ {
+ get;
+ }
+
+ /// <summary>
+ /// You can attach something that you need to
+ /// identify the command.
+ /// </summary>
+ public object ContextData
+ {
+ get { return _contextData; }
+ set { _contextData = value; }
+ }
+
+ public virtual void HandleReply(CommandReply reply)
+ {
+ // a command is only invoked once.
+ if (OnReply != null)
+ {
+ OnReply(this, reply);
+ OnReply = null;
+ }
+ }
+
+ public virtual CommandReply CreateReply(string dataToParse)
+ {
+ return null;
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0} {1}", Command, Arguments);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/CommandReply.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,35 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ /// <summary>
+ /// Baseclass for replies that commands get.
+ /// </summary>
+ public class CommandReply
+ {
+ private bool _success;
+ private string _errCode;
+
+ public CommandReply(bool success)
+ {
+ _success = success;
+ }
+
+ public bool Success
+ {
+ get { return _success; }
+ }
+
+ public string ErrCode
+ {
+ get { return _errCode; }
+ set { _errCode = value; }
+ }
+
+ public override string ToString()
+ {
+ if (_success)
+ return "Success";
+ else
+ return "Failed: " + _errCode;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ExecuteJavascript.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,63 @@
+using System.Collections.Generic;
+
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class ExecuteJavascript : Api
+ {
+ private readonly string _scriptName;
+ private readonly IList<string> _arguments = new List<string>();
+
+ public ExecuteJavascript()
+ {
+
+ }
+
+ public ExecuteJavascript(string scriptName)
+ {
+ _scriptName = scriptName;
+ }
+
+ /// <summary>
+ /// Arguments to javascript
+ /// </summary>
+ /// <seealso cref="Arguments"/>
+ public IList<string> Args
+ {
+ get { return _arguments; }
+ }
+
+ public override string Command
+ {
+ get { return "jsrun"; }
+ }
+
+ /// <summary>
+ /// Args to the CmdBase api
+ /// </summary>
+ /// <seealso cref="Args"/>
+ public override string Arguments
+ {
+ get { return _scriptName + " " + JoinArguments(); }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse == "OK")
+ return new CommandReply(true);
+ else
+ {
+ CommandReply reply = new CommandReply(false);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+
+ private string JoinArguments()
+ {
+ string args = string.Empty;
+ foreach (string arg in Args)
+ args += arg + " ";
+ return args;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/GetVariable.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class GetVariable : Api
+ {
+ private readonly string _channelId;
+ private readonly string _name;
+
+ public GetVariable()
+ {
+
+ }
+
+ public GetVariable(string uuid, string name)
+ {
+ _channelId = uuid;
+ _name = name;
+ }
+
+ public override string Command
+ {
+ get { return "uuid_getvar"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _channelId + " " + _name; }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse.Substring(0, 2) == "OK")
+ {
+ return new GetVariableReply(true, dataToParse.Substring(3));
+ }
+ else
+ {
+ GetVariableReply reply = new GetVariableReply(false, string.Empty);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+ }
+
+
+ public class GetVariableReply : CommandReply
+ {
+ private string _value;
+
+ public GetVariableReply(bool success, string value)
+ : base(success)
+ {
+ _value = value;
+ }
+
+ public string SessionId
+ {
+ get { return _value; }
+ }
+
+ public string Value
+ {
+ get { return _value; }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/HoldCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/HoldCmd.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,29 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class HoldCmd : Api
+ {
+ private readonly string _sessionId;
+ private readonly bool _activate;
+
+ public HoldCmd(string sessionId, bool activate)
+ {
+ _sessionId = sessionId;
+ _activate = activate;
+ }
+
+ public override string Command
+ {
+ get { return "hold"; }
+ }
+
+ public override string Arguments
+ {
+ get { return (_activate ? string.Empty : "off ") + _sessionId; }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ return base.CreateReply(dataToParse);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Originate.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,108 @@
+using System.Collections.Generic;
+using FreeSwitch.EventSocket.General;
+
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class OriginateReply : CommandReply
+ {
+ private readonly string _sessionId;
+
+ public OriginateReply(bool success, string sessionId) : base(success)
+ {
+ _sessionId = sessionId;
+ }
+
+ public string SessionId
+ {
+ get { return _sessionId; }
+ }
+ }
+
+ public class Originate : Api
+ {
+ private SofiaSipAddress _caller;
+ private Address _destination;
+ private readonly IList<ChannelVariable> _variables = new List<ChannelVariable>();
+ private string _callerIdName = null;
+ private string _callerIdNumber = null;
+
+ public Originate()
+ {}
+
+ public Originate(SofiaSipAddress caller, Address destination)
+ {
+ _caller = caller;
+ _destination = destination;
+ }
+
+ public SofiaSipAddress Caller
+ {
+ get { return _caller; }
+ set { _caller = value; }
+ }
+
+ public Address Destination
+ {
+ get { return _destination; }
+ set { _destination = value; }
+ }
+
+ public IList<ChannelVariable> Variables
+ {
+ get { return _variables; }
+ }
+
+ public string CallerIdNumber
+ {
+ get { return _callerIdNumber; }
+ set { _callerIdNumber = value; }
+ }
+
+ public string CallerIdName
+ {
+ get { return _callerIdName; }
+ set { _callerIdName = value; }
+ }
+
+ public override string Command
+ {
+ get { return "originate"; }
+ }
+
+ public override string Arguments
+ {
+ get
+ {
+ _variables.Add(new ChannelVariable("origination_caller_id_name", CallerIdName ?? _caller.Extension));
+ if (!string.IsNullOrEmpty(_callerIdNumber))
+ _variables.Add(new ChannelVariable("origination_caller_id_number", _callerIdNumber));
+
+ string variables = string.Empty;
+ foreach (ChannelVariable var in _variables)
+ variables += var + ",";
+ if (variables.Length > 0)
+ variables = "{" + variables.Remove(variables.Length - 1, 1) + "}";
+
+ return variables + Caller + " " + Destination;
+ }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ dataToParse = dataToParse.Replace(" ", string.Empty);
+ string[] nameValue = dataToParse.Split(':');
+ if (nameValue[0].ToLower() == "success")
+ return new OriginateReply(true, nameValue[1]);
+ else
+ {
+ OriginateReply reply = new OriginateReply(false, string.Empty);
+ if (nameValue.Length > 1)
+ reply.ErrCode = nameValue[1];
+ else
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ParkCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/ParkCmd.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,22 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class ParkCmd : Api
+ {
+ private readonly string _uuid;
+
+ public ParkCmd(string uuid)
+ {
+ _uuid = uuid;
+ }
+
+ public override string Command
+ {
+ get { return "uuid_park"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _uuid; }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/Playback.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,34 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ /// <summary>
+ /// Play a file
+ /// </summary>
+ public class PlaybackCmd : SendMsg
+ {
+ private readonly string _fileName;
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="uuid">channel identifier</param>
+ /// <param name="fileName">Path and filename to sound file</param>
+ /// <remarks>Path should be relative to FS path.</remarks>
+ /// <example>
+ /// mgr.SendApi(new PlaybackCmd(evt.UniqueId, "sounds\\sv\\welcome.wav", PlaybackCmd.All));
+ /// </example>
+ public PlaybackCmd(string uuid, string fileName) : base(uuid)
+ {
+ _fileName = fileName;
+ }
+
+ public override string Command
+ {
+ get { return "playback"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _fileName; }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/RecordCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/RecordCmd.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,72 @@
+using System;
+
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class RecordCmd : Api
+ {
+ //<uuid> [start|stop] <path> [<limit>]
+ private readonly string _uuid;
+ private readonly bool _start;
+ private readonly string _path;
+ private readonly int _limit;
+
+ /// <param name="uuid">channel id</param>
+ /// <param name="path">FS relative path to sound file</param>
+ public RecordCmd(string uuid, string path)
+ {
+ if (string.IsNullOrEmpty(uuid))
+ throw new ArgumentException("uuid");
+ if (string.IsNullOrEmpty(path))
+ throw new ArgumentException("path");
+
+ _uuid = uuid;
+ _path = path;
+ }
+
+ /// <param name="uuid">channel id</param>
+ /// <param name="path">FS relative path to sound file</param>
+ /// <param name="limit">number of seconds that maximum can be recorded.</param>
+ public RecordCmd(string uuid, string path, int limit)
+ {
+ if (string.IsNullOrEmpty(uuid))
+ throw new ArgumentException("uuid");
+ if (string.IsNullOrEmpty(path))
+ throw new ArgumentException("path");
+
+ _uuid = uuid;
+ _path = path;
+ _limit = limit;
+ }
+
+ /// <param name="uuid">channel id</param>
+ /// <param name="path">FS relative path to sound file</param>
+ /// <param name="stop">stop the recording if true</param>
+ public RecordCmd(string uuid, string path, bool stop) : this(uuid, path)
+ {
+ _start = !stop;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="uuid">channel id</param>
+ /// <param name="path">FS relative path to sound file</param>
+ /// <param name="stop">stop the recording if true</param>
+ /// <param name="limit">number of seconds that maximum can be recorded.</param>
+ public RecordCmd(string uuid, string path, bool stop, int limit)
+ : this(uuid, path, limit)
+ {
+ _start = !stop;
+ }
+
+ public override string Command
+ {
+ get { return "uuid_record"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _uuid + (_start ? "start" : "stop") + " " + _path + " " + _limit; }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SendMsg.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,26 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public abstract class SendMsg : CmdBase
+ {
+ private readonly string _uuid;
+ private readonly string _callCommand = "execute";
+
+ public SendMsg(string uuid)
+ {
+ _uuid = uuid;
+ }
+
+ public SendMsg(string uuid, string callCommand)
+ {
+ _callCommand = callCommand;
+ _uuid = uuid;
+ }
+
+ public override string ToString()
+ {
+ return
+ string.Format("SendMsg {0}\ncall-command: {1}\nexecute-app-name: {2}\nexecute-app-arg: {3}\n", _uuid,
+ _callCommand, Command, Arguments);
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SetVariable.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,44 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class SetVariable : Api
+ {
+ private readonly string _channelId;
+ private readonly string _name;
+ private readonly string _value;
+
+ public SetVariable()
+ {
+
+ }
+
+ public SetVariable(string uuid, string name, string value)
+ {
+ _channelId = uuid;
+ _name = name;
+ _value = value;
+ }
+
+ public override string Command
+ {
+ get { return "uuid_setvar"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _channelId + " " + _name + " " + _value; }
+ }
+
+ public override CommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse == "OK")
+ return new CommandReply(true);
+ else
+ {
+ CommandReply reply = new CommandReply(false);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SleepCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/SleepCmd.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,22 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class SleepCmd : SendMsg
+ {
+ private readonly int _ms;
+
+ public SleepCmd(string uuid, int ms) : base(uuid)
+ {
+ _ms = ms;
+ }
+
+ public override string Command
+ {
+ get { return "sleep"; }
+ }
+
+ public override string Arguments
+ {
+ get { return _ms.ToString(); }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/TransferCmd.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Commands/TransferCmd.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,36 @@
+namespace FreeSwitch.EventSocket.Commands
+{
+ public class TransferCmd : PbxCommand
+ {
+ private readonly string _sessionId;
+ private readonly string _destination;
+
+ /// <summary>
+ /// Transfer a call to somewhere.
+ /// </summary>
+ /// <param name="sessionId"></param>
+ /// <param name="destination"></param>
+ public TransferCmd(string sessionId, string destination)
+ {
+ _sessionId = sessionId;
+ _destination = destination;
+ }
+
+ public override PbxCommandReply CreateReply(string dataToParse)
+ {
+ if (dataToParse == "OK")
+ return new PbxCommandReply(true);
+ else
+ {
+ PbxCommandReply reply = new PbxCommandReply(false);
+ reply.ErrCode = dataToParse;
+ return reply;
+ }
+ }
+
+ public override string ToString()
+ {
+ return "transfer " + _sessionId + " " + _destination;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventManager.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,143 @@
+using System;
+using System.Collections.Specialized;
+using System.IO;
+using FreeSwitch.EventSocket.Commands;
+
+namespace FreeSwitch.EventSocket
+{
+ public delegate void EventHandler(EventBase receivedEvent);
+
+ public delegate void EventsWriter(string text);
+
+ public class EventManager
+ {
+ private readonly EventSocket _socket = new EventSocket();
+ public event EventHandler EventReceived;
+ private EventsWriter _writer;
+ private TextWriter _myWriter;
+ public string Password
+ {
+ set { _socket.Password = value; }
+ }
+
+ public EventManager()
+ {
+ _writer = MyWriter;
+ _myWriter = new StreamWriter(new FileStream("C:\\temp\\WatcherRow.log", FileMode.Create, FileAccess.Write, FileShare.ReadWrite));
+ }
+
+ private void MyWriter(string text)
+ {
+ _myWriter.Write(text);
+ }
+
+
+ public EventManager(EventsWriter writer)
+ {
+ _writer = writer;
+ }
+
+ public void Start(string hostname)
+ {
+ _socket.MessageReceived += OnMessage;
+ _socket.Connect(hostname);
+ _socket.DataReceived += OnData;
+ }
+
+ private void OnData(string data)
+ {
+ _writer(data);
+ }
+
+ /// <summary>
+ /// Send a command to the server.
+ /// </summary>
+ /// <param name="cmd"></param>
+ /// <exception cref="IOException">If socket is not connected</exception>
+ /// <exception cref="InvalidOperationException"></exception>
+ /// <exception cref="ObjectDisposedException"></exception>
+ public void Send(CmdBase cmd)
+ {
+ _socket.Send(cmd);
+ }
+
+ public void Send(SendMsg cmd)
+ {
+ _socket.Send(cmd);
+ }
+
+ protected void OnMessage(PlainEventMsg msg)
+ {
+ NameValueCollection parameters = msg.BodyToNameValue(true);
+ string eventName = parameters["event-name"];
+ if (eventName == null)
+ return;
+
+ if (string.Compare(parameters["event-name"], "custom", true) == 0)
+ eventName = parameters["event-subclass"];
+ else
+ eventName = parameters["event-name"];
+
+ //Quickhack for Sofia::Register (convert to sofia_register)
+ eventName = eventName.Replace("::", "_");
+ eventName = StringHelper.UpperCaseToCamelCase(eventName);
+
+ // Try to load the event (check if we've created an event class for the registered event)
+ EventBase eb = EventBase.CreateEvent(eventName);
+
+ // Yep, we got an event class. Let it parse the event information
+ if (eb != null)
+ {
+ eb.SetParameters(parameters);
+ eb.Parse(parameters);
+ if (EventReceived != null)
+ EventReceived(eb);
+
+ /*
+ EventChannelState channel = eb as EventChannelState;
+ if (channel != null)
+ {
+ Console.WriteLine("[" + eb.Name + "/" + channel.ChannelInfo.State + "] (uid: " +
+ channel.UniqueId + ")");
+ Console.WriteLine(" ChannelInfo:");
+ Console.WriteLine(" Name: " + channel.ChannelInfo.Name);
+ Console.WriteLine(" State: " + channel.ChannelInfo.State);
+ if (channel.Caller != null)
+ {
+ Console.WriteLine(" CallerInfo:");
+ Console.WriteLine(" Id: " + channel.Caller.UniqueId);
+ Console.WriteLine(" UserName: " + channel.Caller.UserName);
+ Console.WriteLine(" CallerId: " + channel.Caller.CallerIdName + "/" +
+ channel.Caller.CallerIdNumber);
+ Console.WriteLine(" ChannelName: " + channel.Caller.ChannelName);
+ Console.WriteLine(" DestinationNumber: " + channel.Caller.DestinationNumber);
+ }
+
+ if (channel.Originator != null)
+ {
+ Console.WriteLine(" Originator:");
+ Console.WriteLine(" Id: " + channel.Originator.UniqueId);
+ Console.WriteLine(" UserName: " + channel.Originator.UserName);
+ Console.WriteLine(" CallerId: " + channel.Originator.CallerIdName + "/" +
+ channel.Originator.CallerIdNumber);
+ Console.WriteLine(" ChannelName: " + channel.Originator.ChannelName);
+ Console.WriteLine(" DestinationNumber: " + channel.Originator.DestinationNumber);
+ }
+ }
+ //}*/
+ }
+ else
+ Console.WriteLine("* Failed to load '" + eventName + "'.");
+ }
+
+ public void Subscribe(Events events)
+ {
+ _socket.Subscribe(events);
+ }
+
+ public void Subscribe(params Event[] events)
+ {
+ _socket.Subscribe(new Events(events));
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventParser.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,99 @@
+using EventSocketParser;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventParser
+ {
+ private PlainEventMsg _msg;
+ private readonly StringParser _parser;
+
+ public EventParser(string text)
+ {
+ _parser = new StringParser(text);
+ }
+
+ public PlainEventMsg ParseMessage()
+ {
+ _parser.ClearSavedPositions();
+ _msg = new PlainEventMsg();
+
+ // Save pos if we cant parse the whole message
+ _parser.SavePos();
+
+ ReadHeader();
+ if (!_msg.ValidateHeader())
+ {
+ _parser.RestorePos();
+ return null;
+ }
+
+ // skip empty line between body and header
+ _parser.ReadLine(true);
+
+ // we got no body.
+ if (_msg.ContentLength == -1)
+ return _msg;
+
+ // Unfortunately, \n\n doesnt appear after all content.
+ if (_msg.ContentLength != 0)
+ _msg.Body = _parser.Read(_msg.ContentLength);
+ else
+ _msg.Body = _parser.ReadToEmptyLine();
+
+ // assume that we have not got a complete packet yet.
+ if (!_msg.Validate())
+ {
+ _parser.RestorePos();
+ return null;
+ }
+
+ return _msg;
+ }
+
+ public bool ReadHeader()
+ {
+ // skip empty lines
+ while (!_parser.EOF && _parser.PeekWord(true, true) == string.Empty)
+ _parser.ReadLine(false);
+
+ if (_parser.EOF)
+ return false;
+
+ string name = _parser.Read(':', true);
+ while (name != string.Empty)
+ {
+ switch (name)
+ {
+ case "Content-Length":
+ _msg.ContentLength = int.Parse(_parser.ReadLine(true));
+ break;
+ case "Content-Type":
+ _msg.ContentType = _parser.ReadLine(true);
+ break;
+ case "Reply-Text":
+ _msg.Body = _parser.ReadLine();
+ break;
+ }
+
+ // empty line == end of header
+ if (_parser.EOL)
+ break;
+
+ name = _parser.Read(':', true);
+ }
+
+ return _msg.ContentType != string.Empty;
+ }
+
+ public void Append(string value)
+ {
+ _parser.RemoveUsedContent();
+ _parser.Append(value);
+ }
+
+ public void Clear()
+ {
+ _parser.Clear();
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,298 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading;
+using FreeSwitch.EventSocket.Commands;
+
+namespace FreeSwitch.EventSocket
+{
+ public delegate void MessageHandler(PlainEventMsg msg);
+
+ public class EventSocket
+ {
+ #region Delegates
+
+ public delegate void EventSocketHandler(EventSocket client);
+
+ public delegate void DataHandler(string data);
+
+ #endregion
+
+ private readonly Queue<CmdBase> _commands = new Queue<CmdBase>();
+ private bool _autoConnect = true;
+ private Events _events;
+ private string _hostName;
+ private readonly EventParser _parser = new EventParser(string.Empty);
+ public event DataHandler DataReceived;
+ private string _password = "ClueCon";
+ private int _port = 8021;
+ private object _lockobj = new object();
+ private readonly byte[] _readBuffer = new byte[8192];
+ private string _temp = string.Empty;
+ private Socket _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ private NetworkStream _stream;
+ private Timer _timer;
+ private bool _authed = false;
+ const int RetryTimeout = 5000;
+
+ public string Password
+ {
+ get { return _password; }
+ set { _password = value; }
+ }
+
+ public bool AutoConnect
+ {
+ get { return _autoConnect; }
+ set { _autoConnect = value; }
+ }
+
+ public event MessageHandler MessageReceived;
+
+ public event EventSocketHandler Disconnected;
+ public event EventSocketHandler Connected;
+
+ public void Connect(string server)
+ {
+ int pos = server.IndexOf(':');
+ if (pos == -1)
+ _hostName = server;
+ else
+ {
+ _port = int.Parse(server.Substring(pos + 1));
+ _hostName = server.Substring(0, pos);
+ }
+
+ Connect();
+ }
+
+ public void Connect()
+ {
+ if (_hostName == null)
+ throw new InvalidOperationException("Must call the other Connect method first to set hostname/port.");
+
+ try
+ {
+ TryConnect();
+ }
+ catch (SocketException)
+ {
+ Console.WriteLine("EventSocket: Connect failed");
+ HandleDisconnect();
+ }
+ }
+
+ private void TryConnect()
+ {
+ lock (_lockobj)
+ {
+ Console.WriteLine("EventSocket.TryConnect: Connecting to " + _hostName + ":" + _port);
+
+ _socket.Connect(_hostName, _port);
+ if (_stream == null)
+ _stream = new NetworkStream(_socket, false);
+
+ if (Connected != null)
+ Connected(this);
+ BeginRead();
+
+ if (_timer != null)
+ {
+ Timer tmr = _timer;
+ _timer = null;
+ tmr.Change(Timeout.Infinite, Timeout.Infinite);
+ tmr.Dispose();
+ }
+ }
+ }
+
+ private void BeginRead()
+ {
+ _stream.BeginRead(_readBuffer, 0, _readBuffer.Length, OnReadCompleted, null);
+ }
+
+ private void OnReadCompleted(IAsyncResult ar)
+ {
+ int bytesRead;
+ try
+ {
+ bytesRead = _stream.EndRead(ar);
+ if (bytesRead == 0)
+ {
+ HandleDisconnect();
+ return;
+ }
+ }
+ catch (IOException)
+ {
+ // Remote end disconnected.
+ HandleDisconnect();
+ return;
+ }
+
+ string text = Encoding.ASCII.GetString(_readBuffer, 0, bytesRead);
+ if (DataReceived != null)
+ DataReceived(text);
+ _temp += text;
+ _parser.Append(text);
+ ParseMessages();
+
+ _stream.BeginRead(_readBuffer, 0, _readBuffer.Length, OnReadCompleted, null);
+ }
+
+ /// <summary>
+ /// Subscribe on the specified events.
+ /// </summary>
+ /// <param name="events">The events.</param>
+ public void Subscribe(Events events)
+ {
+ _events = events;
+ if (_socket.Connected && _authed)
+ RequestEvents();
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="s"></param>
+ /// <exception cref="InvalidOperationException"></exception>
+ /// <exception cref="ObjectDisposedException"></exception>
+ private void Write(string s)
+ {
+ if (_socket == null)
+ return;
+ if (!_socket.Connected)
+ {
+ try
+ {
+ Console.WriteLine("EventSocket.Write: Trying to connect eventsocket.");
+ TryConnect();
+ Console.WriteLine("EventSocket.Write: Connected.");
+ }
+ catch (SocketException)
+ {
+ return;
+ }
+ }
+
+ byte[] bytes = Encoding.ASCII.GetBytes(s);
+ _stream.Write(bytes, 0, bytes.Length);
+ }
+
+ private void ParseMessages()
+ {
+ PlainEventMsg msg = _parser.ParseMessage();
+ while (msg != null)
+ {
+ if (msg.ContentType == "auth/request")
+ {
+ AuthCommand cmd = new AuthCommand(_password);
+ cmd.OnReply += OnAuthed;
+ _commands.Enqueue(cmd);
+ Write(cmd + "\n\n");
+ }
+ else if (msg.ContentType == "command/reply"
+ || msg.ContentType == "api/response")
+ {
+ if (_commands.Count > 0)
+ {
+ CmdBase cmd = _commands.Dequeue();
+ Console.WriteLine("Reply to " + cmd.GetType().Name + ": " + msg.Body);
+ cmd.HandleReply(cmd.CreateReply(msg.Body));
+ }
+ else
+ {
+ Console.ForegroundColor = ConsoleColor.Red;
+ Console.WriteLine("Got command reply or api response, but no actual command/api: " + msg.Body);
+ Console.ForegroundColor = ConsoleColor.Gray;
+ }
+ }
+ else
+ {
+ if (MessageReceived != null)
+ MessageReceived(msg);
+ }
+ msg = _parser.ParseMessage();
+ }
+ }
+
+ private void OnAuthed(CmdBase command, CommandReply reply)
+ {
+ _authed = true;
+ RequestEvents();
+ }
+
+ private void HandleDisconnect()
+ {
+ _parser.Clear();
+ _authed = false;
+ _socket.Close();
+ _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ if (_stream != null)
+ {
+ _stream.Dispose();
+ _stream = null;
+ }
+
+ if (Disconnected != null)
+ Disconnected.Invoke(this);
+ if (AutoConnect && _timer == null)
+ {
+ Console.WriteLine("EventSocket: Launching timer.");
+ _timer = new Timer(TryConnect, this, RetryTimeout, RetryTimeout);
+ }
+ }
+
+ private void RequestEvents()
+ {
+ if (_events.Count <= 0 && _authed)
+ return;
+
+ Write("event plain " + GetEventString() + "\n\n");
+ }
+
+ private string GetEventString()
+ {
+ string events = string.Empty;
+ for (int i = 0; i < _events.Count; ++i)
+ events += StringHelper.CamelCaseToUpperCase(_events[i].ToString()) + " ";
+ return events;
+ }
+
+ /// <summary>
+ /// Send a command to FreeSwitch.
+ /// Do you want a response? Then use the delegate in the Command class.
+ /// </summary>
+ /// <param name="command">Command to send.</param>
+ /// <exception cref="IOException">If socket is not connected.</exception>
+ /// <exception cref="InvalidOperationException"></exception>
+ /// <exception cref="ObjectDisposedException"></exception>
+ public void Send(CmdBase command)
+ {
+ if (!_socket.Connected)
+ throw new IOException("Socket is not connected.");
+
+ _commands.Enqueue(command);
+
+ // All commands need replies.
+ Write(command + "\n\n");
+ }
+
+ private static void TryConnect(object state)
+ {
+ EventSocket client = (EventSocket) state;
+ try
+ {
+ Console.WriteLine("EventSocket.Timer: Trying to connect eventsocket.");
+ client.TryConnect();
+ Console.WriteLine("EventSocket.Timer: Connected.");
+ }
+ catch (SocketException err)
+ {
+ Console.WriteLine("Eventsocket.TryConnect: " + err.Message);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/EventSocket.pfx
==============================================================================
Binary file. No diff available.
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,107 @@
+using System.Collections.Generic;
+
+namespace FreeSwitch.EventSocket
+{
+ #region Event enum
+ public enum Event
+ {
+ Custom,
+ ChannelCreate,
+ ChannelDestroy,
+ ChannelState,
+ ChannelAnswer,
+ ChannelApplication,
+ ChannelHangup,
+ ChannelExecute,
+ ChannelExecuteComplete,
+ ChannelBridge,
+ ChannelUnbridge,
+ ChannelProgress,
+ ChannelOriginate,
+ ChannelOutgoing,
+ ChannelPark,
+ ChannelUnpark,
+ Api,
+ Log,
+ InboundChan,
+ OutboundChan,
+ Startup,
+ Shutdown,
+ Publish,
+ Unpublish,
+ Talk,
+ Notalk,
+ SessionCrash,
+ ModuleLoad,
+ Dtmf,
+ Message,
+ PresenceIn,
+ PresenceOut,
+ PresenceProbe,
+ SofiaRegister,
+ SofiaExpires,
+ Roster,
+ Codec,
+ BackgroundJob,
+ DetectedSpeech,
+ PrivateCommand,
+ Heartbeat,
+ All
+ }
+ #endregion
+
+ #region Events class
+ public class Events
+ {
+ private IList<Event> m_events = new List<Event>();
+
+ public Events() { }
+ public Events(params Event[] parameters)
+ {
+ foreach (Event e in parameters)
+ {
+ Add(e);
+ }
+ }
+
+ public void Add(Event e)
+ {
+ m_events.Add(e);
+ }
+
+ public Event this[int index]
+ {
+ get { return m_events[index]; }
+ }
+
+ public void Clear()
+ {
+ m_events.Clear();
+ }
+
+ public int Count
+ {
+ get { return m_events.Count; }
+ }
+
+ public static Events GetChannelEvents()
+ {
+ Events e = new Events();
+ e.Add(Event.ChannelAnswer);
+ e.Add(Event.ChannelBridge);
+ e.Add(Event.ChannelCreate);
+ e.Add(Event.ChannelDestroy);
+ e.Add(Event.ChannelExecute);
+ e.Add(Event.ChannelHangup);
+ e.Add(Event.ChannelOutgoing);
+ e.Add(Event.ChannelPark);
+ e.Add(Event.ChannelProgress);
+ e.Add(Event.ChannelState);
+ e.Add(Event.ChannelUnbridge);
+ e.Add(Event.ChannelUnpark);
+ return e;
+ }
+ }
+ #endregion
+
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventApiCommand.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventApiCommand.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ class EventApiCommand : EventBase
+ {
+ private string m_command;
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "api-command":
+ m_command = value;
+ break;
+ default:
+ return base.ParseCommand(name, value);
+ }
+
+ return true;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventBase.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,139 @@
+using System;
+using System.Collections.Specialized;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventBase
+ {
+ private string m_callingFile;
+ private string m_callingFunction;
+ private int m_callingLineNumber;
+ private string m_coreId;
+ private DateTime m_dateGMT;
+ private DateTime m_dateLocal;
+ private string m_name;
+ private readonly NameValueCollection _parameters = new NameValueCollection();
+ private NameValueCollection _allParameters;
+
+ #region Properties
+
+ public string Name
+ {
+ get { return m_name; }
+ set { m_name = value; }
+ }
+
+ public string CoreId
+ {
+ get { return m_coreId; }
+ set { m_coreId = value; }
+ }
+
+ public DateTime DateLocal
+ {
+ get { return m_dateLocal; }
+ set { m_dateLocal = value; }
+ }
+
+ public DateTime DateGMT
+ {
+ get { return m_dateGMT; }
+ set { m_dateGMT = value; }
+ }
+
+ public string CallingFile
+ {
+ get { return m_callingFile; }
+ set { m_callingFile = value; }
+ }
+
+ public string CallingFunction
+ {
+ get { return m_callingFunction; }
+ set { m_callingFunction = value; }
+ }
+
+ public int CallingLineNumber
+ {
+ get { return m_callingLineNumber; }
+ set { m_callingLineNumber = value; }
+ }
+
+ #endregion
+
+ public virtual bool IsChannelEvent
+ {
+ get { return false; }
+ }
+
+ public NameValueCollection Parameters
+ {
+ get { return _parameters; }
+ }
+
+ public NameValueCollection AllParameters
+ {
+ get { return _allParameters; }
+ }
+
+ internal void SetParameters(NameValueCollection allparams)
+ {
+ _allParameters = allparams;
+ }
+
+ public void Parse(NameValueCollection variables)
+ {
+ for (int i = 0; i < variables.Count; ++i)
+ ParseCommand(variables.GetKey(i), variables.Get(i));
+ }
+
+ public static EventBase CreateEvent(string eventName)
+ {
+ try
+ {
+ string eventNamea = "Event" + eventName;
+ Type t = Type.GetType("FreeSwitch.EventSocket.Event" + eventName);
+ if (t == null)
+ return null;
+ return (EventBase) Activator.CreateInstance(t);
+ }
+ catch (TypeLoadException)
+ {
+ return null;
+ }
+ }
+
+ public virtual bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "event-name":
+ m_name = value;
+ break;
+ case "core-uuid":
+ m_coreId = value;
+ break;
+ case "event-date-local":
+ m_dateLocal = DateTime.Parse(value);
+ break;
+ case "event-date-gmt":
+ m_dateGMT = DateTime.Parse(value);
+ break;
+ case "event-calling-file":
+ m_callingFile = value;
+ break;
+ case "event-calling-function":
+ m_callingFunction = value;
+ break;
+ case "event-calling-line-number":
+ int.TryParse(value, out m_callingLineNumber);
+ break;
+ default:
+ Parameters.Add(name, value);
+ //Console.WriteLine(m_name + ", Unhandled parameter: [" + name + "] " + value);
+ return false;
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventHeartbeat.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventHeartbeat.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,57 @@
+namespace FreeSwitch.EventSocket
+{
+ class EventHeartbeat : EventBase
+ {
+ private string _info;
+ private string _upTime;
+ private int _sessionCount;
+
+ public string Info
+ {
+ get { return _info; }
+ set { _info = value; }
+ }
+
+ public string UpTime
+ {
+ get { return _upTime; }
+ set { _upTime = value; }
+ }
+
+ public int SessionCount
+ {
+ get { return _sessionCount; }
+ set { _sessionCount = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "event-info":
+ Info = value;
+ break;
+ case "up-time":
+ UpTime = value;
+ break;
+ case "session-count":
+ int.TryParse(value, out _sessionCount);
+ break;
+
+ default:
+ return base.ParseCommand(name, value);
+ }
+
+ return true;
+
+ }
+ }
+
+/*
+ Event-Info: System%20Ready
+Up-Time: 0%20years,%200%20days,%201%20hour,%2048%20minutes,%207%20seconds,%20265
+%20milliseconds,%20625%20microseconds%0A
+Session-Count: 0
+Event-Name: HEARTBEAT
+ */
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageQuery.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageQuery.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class EventMessageQuery : EventBase
+ {
+ private string _account;
+
+ public string Account
+ {
+ get { return _account; }
+ set { _account = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ if (name == "message-account")
+ Account = value;
+ else
+ return base.ParseCommand(name, value);
+
+ return true;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventMessageWaiting.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,133 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventMessageWaiting : EventBase
+ {
+ private string _account;
+ private int _newMessages;
+ private int _newUrgentMessages;
+ private int _totalMessages;
+ private int _totalUrgentMessages;
+
+ /// <summary>
+ /// Messages are for this account
+ /// </summary>
+ public string Account
+ {
+ get { return _account; }
+ set { _account = value; }
+ }
+
+ /// <summary>
+ /// Total count of messages
+ /// </summary>
+ public bool MessagesWaiting
+ {
+ get { return _newMessages != 0 || _newUrgentMessages != 0; }
+ }
+
+ /// <summary>
+ /// Number of new messages
+ /// </summary>
+ public int NewMessages
+ {
+ get { return _newMessages; }
+ set { _newMessages = value; }
+ }
+
+ /// <summary>
+ /// Number of new urgent messages
+ /// </summary>
+ public int NewUrgentMessages
+ {
+ get { return _newUrgentMessages; }
+ set { _newUrgentMessages = value; }
+ }
+
+ /// <summary>
+ /// Total number of new/saved/old messages
+ /// </summary>
+ public int TotalMessages
+ {
+ get { return _totalMessages; }
+ set { _totalMessages = value; }
+ }
+
+ /// <summary>
+ /// Total number of new urgent messages
+ /// </summary>
+ public int TotalUrgentMessages
+ {
+ get { return _totalUrgentMessages; }
+ set { _totalUrgentMessages = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "mwi-messages-waiting":
+ // are calculated by using voice messages
+ break;
+ case "mwi-message-account":
+ _account = value;
+ break;
+ case "mwi-voice-message":
+ return ParseVoiceMessages(value);
+ default:
+ return base.ParseCommand(name, value);
+ }
+
+ return true;
+ }
+
+ private bool ParseVoiceMessages(string value)
+ {
+ /*
+ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)",
+ total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
+ * */
+ int pos = value.IndexOf('/');
+ if (pos == -1)
+ return false;
+ if (!int.TryParse(value.Substring(0, pos), out _newMessages))
+ return false;
+
+ int oldPos = pos + 1;
+ pos = value.IndexOf(' ', pos);
+ if (pos == -1)
+ return false;
+ if (!int.TryParse(value.Substring(oldPos, pos - oldPos), out _totalMessages))
+ return false;
+
+ oldPos = pos + 2;
+ pos = value.IndexOf('/', pos);
+ if (pos == -1)
+ return false;
+ if (!int.TryParse(value.Substring(oldPos, pos - oldPos), out _newUrgentMessages))
+ return false;
+
+ oldPos = pos + 1;
+ pos = value.IndexOf(')', pos);
+ if (pos == -1)
+ return false;
+ if (!int.TryParse(value.Substring(oldPos, pos - oldPos), out _totalUrgentMessages))
+ return false;
+
+ return true;
+ }
+
+ public override string ToString()
+ {
+ string str = base.ToString();
+ str += "WMI-Messages-Waiting: " + (MessagesWaiting ? "yes" : "no") + "\n";
+ str += "WMI-Message-Account: " + _account + "\n";
+ if (_newUrgentMessages != 0 || _newMessages != 0)
+ str += string.Format("WMI-Voice-Message: {0}/{1} ({2}/{3})\n",
+ _newMessages,
+ _totalMessages,
+ _newMessages,
+ _totalUrgentMessages);
+ return str;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventReSchedule.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Events/EventReSchedule.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ class EventReSchedule : EventBase
+ {
+ private int m_taskId;
+ private string m_description;
+ private string m_group;
+ private string m_runtime;
+
+ public int TaskId
+ {
+ get { return m_taskId; }
+ set { m_taskId = value; }
+ }
+
+ public string Description
+ {
+ get { return m_description; }
+ set { m_description = value; }
+ }
+
+ public string Group
+ {
+ get { return m_group; }
+ set { m_group = value; }
+ }
+
+ public string Runtime
+ {
+ get { return m_runtime; }
+ set { m_runtime = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "task-id":
+ int.TryParse(value, out m_taskId);
+ break;
+ case "task-desc":
+ m_description = value;
+ break;
+ case "task-group":
+ m_group = value;
+ break;
+ case "task-runtime":
+ m_runtime = value;
+ break;
+ default:
+ return base.ParseCommand(name, value);
+ }
+
+ return true;
+
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/FreeSwitch.EventSocket.csproj Thu May 1 14:27:39 2008
@@ -0,0 +1,123 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{3F8895F6-F710-4323-B96A-4EFB6BC97E08}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>FreeSwitch.EventSocket</RootNamespace>
+ <AssemblyName>FreeSwitch.EventSocket</AssemblyName>
+ <StartupObject>
+ </StartupObject>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>EventSocket.pfx</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="Tiny.Net, Version=1.0.0.1, Culture=neutral, PublicKeyToken=15480ee9e0247fcb, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\dlls\Debug\Tiny.Net.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ChannelEvents\EventChannelApplication.cs" />
+ <Compile Include="ChannelEvents\EventChannelExecuteComplete.cs" />
+ <Compile Include="ChannelEvents\EventChannelOriginate.cs" />
+ <Compile Include="ChannelEvents\EventChannelBridge.cs" />
+ <Compile Include="ChannelEvents\ChannelEvent.cs" />
+ <Compile Include="ChannelEvents\EventChannelAnswer.cs" />
+ <Compile Include="ChannelEvents\EventChannelProgress.cs" />
+ <Compile Include="ChannelEvents\EventChannelUnbridge.cs" />
+ <Compile Include="ChannelEvents\EventChannelUnpark.cs" />
+ <Compile Include="ChannelEvents\EventCodec.cs" />
+ <Compile Include="ChannelInfo.cs" />
+ <Compile Include="Commands\AnyCommand.cs">
+ </Compile>
+ <Compile Include="Commands\Api.cs" />
+ <Compile Include="Commands\AuthCommand.cs" />
+ <Compile Include="Commands\CmdBase.cs" />
+ <Compile Include="Commands\CommandReply.cs" />
+ <Compile Include="Commands\ExecuteJavascript.cs" />
+ <Compile Include="Commands\GetVariable.cs" />
+ <Compile Include="Commands\HoldCmd.cs" />
+ <Compile Include="Commands\Originate.cs" />
+ <Compile Include="Commands\ParkCmd.cs" />
+ <Compile Include="Commands\Playback.cs" />
+ <Compile Include="Commands\RecordCmd.cs" />
+ <Compile Include="Commands\SendMsg.cs" />
+ <Compile Include="Commands\SetVariable.cs" />
+ <Compile Include="Commands\SleepCmd.cs" />
+ <Compile Include="EventManager.cs" />
+ <Compile Include="ChannelEvents\EventDtmfStatus.cs" />
+ <Compile Include="Ivr\IvrInterface.cs" />
+ <Compile Include="PlainEventMsg.cs" />
+ <Compile Include="EventParser.cs" />
+ <Compile Include="Events.cs" />
+ <Compile Include="Events\EventApiCommand.cs" />
+ <Compile Include="Events\EventBase.cs" />
+ <Compile Include="ChannelEvents\EventChannelCreate.cs" />
+ <Compile Include="ChannelEvents\EventChannelDestroy.cs" />
+ <Compile Include="ChannelEvents\EventChannelExecute.cs" />
+ <Compile Include="ChannelEvents\EventChannelHangup.cs" />
+ <Compile Include="ChannelEvents\EventChannelOutgoing.cs" />
+ <Compile Include="ChannelEvents\EventChannelState.cs" />
+ <Compile Include="EventSocket.cs" />
+ <Compile Include="Events\EventHeartbeat.cs" />
+ <Compile Include="Events\EventReSchedule.cs" />
+ <Compile Include="General\Address.cs" />
+ <Compile Include="General\ChannelVariable.cs" />
+ <Compile Include="General\SipAddress.cs" />
+ <Compile Include="General\SofiaSipAddress.cs" />
+ <Compile Include="PartyInfo.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Events\EventMessageQuery.cs" />
+ <Compile Include="ChannelEvents\EventDtmf.cs" />
+ <Compile Include="SipEvents\EventPresenceIn.cs" />
+ <Compile Include="SipEvents\EventPresenceOut.cs" />
+ <Compile Include="SipEvents\EventPresenceProbe.cs" />
+ <Compile Include="SipEvents\EventRoster.cs" />
+ <Compile Include="Events\EventMessageWaiting.cs" />
+ <Compile Include="SipEvents\SipEvent.cs" />
+ <Compile Include="SipEvents\EventPresence.cs" />
+ <Compile Include="SipEvents\EventSofiaExpire.cs" />
+ <Compile Include="SipEvents\EventSofiaRegister.cs" />
+ <Compile Include="StringHelper.cs" />
+ <Compile Include="StringParser.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="EventSocket.pfx" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+ <PropertyGroup>
+ <PostBuildEvent>copy $(TargetPath) $(SolutionDir)..\..\dlls\$(ConfigurationName)</PostBuildEvent>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/Address.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/Address.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.General
+{
+ public class Address
+ {
+ private string _extension;
+
+ public Address()
+ {
+
+ }
+
+ public Address(string extension)
+ {
+ _extension = extension;
+ }
+
+ public string Extension
+ {
+ get { return _extension; }
+ set { _extension = value; }
+ }
+
+ public override string ToString()
+ {
+ return Extension;
+ }
+ }
+
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/ChannelVariable.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/ChannelVariable.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+namespace FreeSwitch.EventSocket.General
+{
+ /// <summary>
+ /// Channel variables are used in freeswitch to store information
+ /// that can be used by javascript programs.
+ /// </summary>
+ public class ChannelVariable
+ {
+ private readonly string _name;
+ private readonly string _value;
+
+ public ChannelVariable(string name, string value)
+ {
+ _name = name;
+ _value = value;
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ public string Value
+ {
+ get { return _value; }
+ }
+
+ public override string ToString()
+ {
+ return _name + "=" + _value;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SipAddress.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SipAddress.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.General
+{
+ public class SipAddress : Address
+ {
+ private string _domain;
+
+ public SipAddress(string domain, string extension)
+ : base(extension)
+ {
+ _domain = domain;
+ }
+
+ public string Domain
+ {
+ get { return _domain; }
+ set { _domain = value; }
+ }
+
+ public override string ToString()
+ {
+ return Extension + "@" + Domain;
+ }
+
+ public static SipAddress Parse(string fullAddress)
+ {
+ string[] parts = fullAddress.Split('@');
+ if (parts.Length == 2)
+ {
+ return new SipAddress(parts[1], parts[0]);
+ }
+ return null;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SofiaSipAddress.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/General/SofiaSipAddress.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,44 @@
+namespace FreeSwitch.EventSocket.General
+{
+ public class SofiaSipAddress : Address
+ {
+ private readonly string _domain;
+
+ public SofiaSipAddress(string domain, string userName)
+ {
+ Extension = userName;
+ _domain = domain;
+ }
+
+ public SofiaSipAddress(SipAddress address)
+ {
+ _domain = address.Domain;
+ Extension = address.Extension;
+ }
+
+ public override string ToString()
+ {
+ return "sofia/mydomain.com/" + Extension + "%" + _domain;
+ }
+
+ public static SofiaSipAddress Parse(string fullAddress)
+ {
+ string[] parts = fullAddress.Split('@');
+ if (parts.Length == 2)
+ {
+ return new SofiaSipAddress(parts[1], parts[0]);
+ }
+ else
+ {
+ parts = fullAddress.Split('/');
+ if (parts.Length == 3)
+ {
+ return new SofiaSipAddress(parts[1], parts[2]);
+ }
+ }
+
+ return null;
+
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Ivr/IvrInterface.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,212 @@
+using System;
+using System.Threading;
+using FreeSwitch.EventSocket.Commands;
+
+namespace FreeSwitch.EventSocket.Ivr
+{
+ public class IvrInterface
+ {
+ public const string AllDigits = "*#0123456789";
+ private readonly string _uuid;
+ private readonly string _baseSoundPath = "sounds\\";
+ private string _dtmf = string.Empty;
+ private EventManager _mgr;
+ public event DtmfHandler DtmfReceived;
+ private readonly int _dtmfWaitCount = 0;
+ private ManualResetEvent _dtmfWaitEvent;
+ private bool _abortSpeechOnDtmf;
+ private bool _answered;
+ private IvrInterfaceHandler _handler = null;
+ private string _lastAbortDigits = "*";
+
+ public IvrInterface(EventManager mgr, string uuid)
+ {
+ if (mgr == null)
+ throw new ArgumentNullException("mgr");
+ if (string.IsNullOrEmpty(uuid))
+ throw new ArgumentNullException("uuid");
+
+ _mgr = mgr;
+ mgr.EventReceived += OnEvent;
+ _uuid = uuid;
+
+ mgr.Send(new ParkCmd(uuid));
+ }
+
+ public IAsyncResult BeginInvoke(IvrInterfaceHandler handler, AsyncCallback callback, object state)
+ {
+ _handler = handler;
+ return handler.BeginInvoke(this, callback, state);
+ }
+
+ public void EndInvoke(IAsyncResult result)
+ {
+ if (_handler != null)
+ _handler.EndInvoke(result);
+ }
+
+ /// <summary>
+ /// dont play phrases as long as we have DTMF in the buffer.
+ /// </summary>
+ public bool AbortSpeechOnDtmf
+ {
+ get { return _abortSpeechOnDtmf; }
+ set { _abortSpeechOnDtmf = value; }
+ }
+
+ public bool Answered
+ {
+ get { return _answered; }
+ }
+
+ private void OnEvent(EventBase receivedEvent)
+ {
+ if (receivedEvent is EventChannelAnswer)
+ {
+ _answered = true;
+ }
+/* else if (receivedEvent is EventDtmfStatus)
+ {
+ // Let's always dequeue dtmf.
+ EventDtmfStatus evt = (EventDtmfStatus) receivedEvent;
+ if (evt.UniqueId == _uuid)
+ _mgr.Send(new GetDtmfCmd(_uuid, evt.Count));
+ }*/
+ else if (receivedEvent is EventDtmf)
+ {
+ EventDtmf evt = (EventDtmf) receivedEvent;
+ lock (_dtmf)
+ _dtmf += evt.Digit;
+ if (_dtmfWaitCount >= _dtmf.Length)
+ _dtmfWaitEvent.Set();
+
+ if (DtmfReceived != null)
+ DtmfReceived(this, new DtmfEventArgs(_dtmf));
+ }
+ else if (receivedEvent is EventChannelDestroy || receivedEvent is EventChannelHangup)
+ {
+ if (_mgr != null)
+ {
+ _mgr.EventReceived -= OnEvent;
+ _mgr = null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Wait on dtmf.
+ /// </summary>
+ /// <param name="count">Number of digits to get</param>
+ /// <param name="timeout">number of seconds to wait on all digits.</param>
+ /// <remarks>You can also used the Dtmf event if you want to use asynchrounous programming.</remarks>
+ /// <seealso cref="DtmfReceived"/>
+ public string GetDtmf(int count, int timeout)
+ {
+ if (_mgr == null)
+ return string.Empty;
+ if (_dtmfWaitEvent != null)
+ throw new InvalidOperationException("Already waiting on an event.");
+
+ if (_dtmf.Length < count)
+ {
+ _dtmfWaitEvent = new ManualResetEvent(false);
+ if (!_dtmfWaitEvent.WaitOne(timeout * 1000, true))
+ {
+ _dtmf = string.Empty;
+ return string.Empty;
+ }
+ }
+
+ lock (_dtmf)
+ {
+ if (_dtmf.Length >= count)
+ {
+ string dtmf = _dtmf.Substring(0, count);
+ _dtmf = _dtmf.Remove(count);
+ return dtmf;
+ }
+ }
+
+ return string.Empty;
+ }
+
+ public void Play(string path, string digitsToAbortOn)
+ {
+ if (_mgr == null)
+ return;
+
+ if (_abortSpeechOnDtmf && _dtmf != string.Empty)
+ return;
+
+ if (digitsToAbortOn != _lastAbortDigits)
+ {
+ _mgr.Send(new SetVariable(_uuid, "playback_terminators", digitsToAbortOn));
+ _lastAbortDigits = digitsToAbortOn;
+ }
+
+ _mgr.Send(new PlaybackCmd(_uuid, _baseSoundPath + path));
+ }
+
+ public void Record(string path, bool stop, int limit)
+ {
+ if (_mgr == null)
+ return;
+ _mgr.Send(new RecordCmd(_uuid, _baseSoundPath + path, stop, limit));
+ }
+
+ public void Record(string path, int limit)
+ {
+ if (_mgr == null)
+ return;
+ _mgr.Send(new RecordCmd(_uuid, _baseSoundPath + path, limit));
+ }
+
+ public void Sleep(int ms)
+ {
+ if (_mgr == null)
+ return;
+ _mgr.Send(new SleepCmd(_uuid, ms));
+ }
+ }
+
+ public class DtmfEventArgs : EventArgs
+ {
+ private string _dtmf;
+ private string _dtmfCopy;
+
+ public DtmfEventArgs(string dtmf)
+ {
+ _dtmf = dtmf;
+ _dtmfCopy = (string) _dtmf.Clone();
+ }
+
+ /// <summary>
+ /// You cannot remove digits from the buffer (since it's a copy of the real buffer).
+ /// </summary>
+ /// <seealso cref="RemoveDigits"/>
+ public string Dtmf
+ {
+ get { return _dtmfCopy; }
+ }
+
+ /// <summary>
+ /// Remove digits from the real buffer.
+ /// </summary>
+ /// <param name="count">number of digits to remove.</param>
+ public void RemoveDigits(int count)
+ {
+ lock (_dtmf)
+ {
+ if (count > _dtmf.Length)
+ _dtmf = string.Empty;
+ else
+ _dtmf = _dtmf.Remove(0, count);
+ _dtmfCopy = (string)_dtmf.Clone();
+ }
+ }
+ }
+
+ public delegate void DtmfHandler(object source, DtmfEventArgs args);
+
+ public delegate void IvrInterfaceHandler(IvrInterface app);
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PartyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PartyInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,150 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ public class PartyInfo
+ {
+ private string m_userName = string.Empty;
+ private string m_dialplan = string.Empty;
+ private string m_callerIdName = string.Empty;
+ private string m_callerIdNumber = string.Empty;
+ private string m_destinationNumber = string.Empty;
+ private string m_uniqueId = string.Empty;
+ private string m_source = string.Empty;
+ private string m_context = string.Empty;
+ private string m_channelName = string.Empty;
+ private bool m_screenBit;
+ private bool m_privacyHideName;
+ private bool m_privacyHideNumber;
+
+ public PartyInfo()
+ {
+ m_userName = string.Empty;
+ m_dialplan = string.Empty;
+ m_callerIdName = string.Empty;
+ }
+
+ public string Dialplan
+ {
+ get { return m_dialplan; }
+ set { m_dialplan = value; }
+ }
+
+ public string CallerIdName
+ {
+ get { return m_callerIdName; }
+ set { m_callerIdName = value; }
+ }
+
+ public string CallerIdNumber
+ {
+ get { return m_callerIdNumber; }
+ set { m_callerIdNumber = value; }
+ }
+
+ public string DestinationNumber
+ {
+ get { return m_destinationNumber; }
+ set { m_destinationNumber = value; }
+ }
+
+ public string UniqueId
+ {
+ get { return m_uniqueId; }
+ set { m_uniqueId = value; }
+ }
+
+ public string Source
+ {
+ get { return m_source; }
+ set { m_source = value; }
+ }
+
+ public string Context
+ {
+ get { return m_context; }
+ set { m_context = value; }
+ }
+
+ public string ChannelName
+ {
+ get { return m_channelName; }
+ set { m_channelName = value; }
+ }
+
+ public bool ScreenBit
+ {
+ get { return m_screenBit; }
+ set { m_screenBit = value; }
+ }
+
+ public bool PrivacyHideName
+ {
+ get { return m_privacyHideName; }
+ set { m_privacyHideName = value; }
+ }
+
+ public bool PrivacyHideNumber
+ {
+ get { return m_privacyHideNumber; }
+ set { m_privacyHideNumber = value; }
+ }
+
+ public string UserName
+ {
+ get { return m_userName; }
+ set { m_userName = value; }
+ }
+
+ public bool Parse(string name, string value)
+ {
+ switch (name)
+ {
+ case "username":
+ m_userName = value;
+ break;
+ case "dialplan":
+ Dialplan = value;
+ break;
+ case "caller-id-name":
+ CallerIdName = value;
+ break;
+ case "caller-id-number":
+ CallerIdNumber = value;
+ break;
+ case "destination-number":
+ DestinationNumber = value;
+ break;
+ case "unique-id":
+ UniqueId = value;
+ break;
+ case "source":
+ Source = value;
+ break;
+ case "context":
+ Context = value;
+ break;
+ case "channel-name":
+ ChannelName = value;
+ break;
+ case "screen-bit":
+ ScreenBit = value == "yes";
+ break;
+ case "privacy-hide-name":
+ PrivacyHideName = value == "yes";
+ break;
+ case "privacy-hide-number":
+ PrivacyHideNumber = value == "yes";
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+
+ }
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PlainEventMsg.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/PlainEventMsg.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Specialized;
+using EventSocketParser;
+
+namespace FreeSwitch.EventSocket
+{
+ public class PlainEventMsg
+ {
+ private string _contentType = string.Empty;
+ private int _contentLength = -1;
+ private string _body = string.Empty;
+
+ public string ContentType
+ {
+ get { return _contentType; }
+ set { _contentType = value; }
+ }
+
+ public int ContentLength
+ {
+ get { return _contentLength; }
+ set { _contentLength = value; }
+ }
+
+ public string Body
+ {
+ get { return _body; }
+ set { _body = value; }
+ }
+
+ public bool ValidateHeader()
+ {
+ if (_contentType == string.Empty)
+ return false;
+ if (_contentType == "command/reply")
+ return _body != string.Empty;
+
+ return true;
+ }
+
+ public bool Validate()
+ {
+ if (!ValidateHeader())
+ return false;
+
+ if (_contentLength > 0)
+ return _contentLength == _body.Length || _contentLength == _body.Length + 2; // include first and last line breaks that we skip in parsing
+
+ return true;
+ }
+
+
+ public NameValueCollection BodyToNameValue(bool urlDecodeValues)
+ {
+ NameValueCollection items = new NameValueCollection();
+ StringParser parser = new StringParser(_body);
+ string name = parser.Read(':', true);
+ while (!parser.EOF && name != string.Empty)
+ {
+ string value = parser.ReadLine(true);
+ if (items[name] == null)
+ {
+ try
+ {
+ items.Add(name.ToLower(), Uri.UnescapeDataString(value));
+ }
+ catch (UriFormatException)
+ {
+ // add the value unformatted
+ items.Add(name.ToLower(), value);
+ }
+ }
+
+ name = parser.Read(':', true);
+ }
+
+ return items;
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Program.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Program.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using FreeSwitch.EventSocket;
+
+namespace FreeSwitch.EventSocket
+{
+ class Program
+ {
+ /// <summary>
+ /// This method is called by the event delegate.
+ /// </summary>
+ /// <param name="eb">Reference to an event, each event has their own class.</param>
+ void HandleEvent(EventBase eb)
+ {
+ //Console.WriteLine(eb.DateLocal + " Got Event: " + eb.Name);
+
+
+ if (eb is EventChannelHangup)
+ Console.WriteLine(eb.DateLocal + " Hangup reason: " + ((EventChannelHangup)eb).Cause.ToString());
+ }
+
+ static void Main(string[] args)
+ {
+ Program p = new Program();
+
+ /// Create a new FreeSwitch event socket.
+ EventManager eventManager = new EventManager();
+
+ // Hook all events to the same delegate. Can also provide one delegate per event.
+ eventManager.EventReceived += p.HandleEvent;
+ eventManager.Subscribe(new Events(Event.All));
+
+ // Connect to localhost
+ eventManager.Start("localhost");
+
+
+ System.Threading.Thread.Sleep(1000000);
+
+ //a.
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/Properties/AssemblyInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("FreeSwitch.EventSocket")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("FreeSwitch.EventSocket")]
+[assembly: AssemblyCopyright("Copyright © 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("db16a54e-3305-4b56-92a1-70cc95179bc6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresence.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresence.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,112 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventPresence : SipEvent
+ {
+ private PartyInfo _caller;
+ private string _rpid = string.Empty;
+ private string _status = string.Empty;
+ //private string _callId; // not "presencein/register", "presenceout/register"
+ //private string _contact; // not "presencein/register", "presenceout/register"
+ //private string _expires; //not "presencein/register", "presenceout/register"
+ private string _eventType = string.Empty;
+ private string _login = string.Empty;
+ private EventChannelState _channelState;
+
+ public string Login
+ {
+ get { return _login; }
+ set { _login = value; }
+ }
+
+ /// <summary>
+ /// "Click to call", "Registered", "unavailable", "Active (%d waiting)", "Idle"
+ /// </summary>
+ public string Status
+ {
+ get { return _status; }
+ set { _status = value; }
+ }
+
+ public string Rpid
+ {
+ get { return _rpid; }
+ set { _rpid = value; }
+ }
+
+ /// <summary>
+ /// Caller is only specified on state CS_RING
+ /// and not on CS_HANGUP
+ /// </summary>
+ public PartyInfo Caller
+ {
+ get { return _caller; }
+ set { _caller = value; }
+ }
+
+ /// <summary>
+ /// presence,
+ /// </summary>
+ public string PresenceEventType
+ {
+ get { return _eventType; }
+ set { _eventType = value; }
+ }
+
+ /// <summary>
+ /// We *may* have channel state info
+ /// </summary>
+ public EventChannelState ChannelState
+ {
+ get { return _channelState; }
+ set { _channelState = value; }
+ }
+
+
+ /*
+ proto: sip
+ login: sip%3Amod_sofia%40192.168.0.58%3A5070
+ rpid: unknown
+ from: gauffin%40gauffin.com
+ status: Registered
+ * */
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "status":
+ _status = value;
+ break;
+ case "rpid":
+ _rpid = value;
+ break;
+ case "login":
+ _login = value;
+ break;
+ case "event_type":
+ _eventType = value;
+ break;
+
+ default:
+ if (name.Length > 7 && name.Substring(0, 7) == "caller-")
+ {
+ if (Caller == null)
+ Caller = new PartyInfo();
+ return Caller.Parse(name.Substring(7), value);
+ }
+ else
+ {
+ if (base.ParseCommand(name, value))
+ return true;
+ else
+ {
+ if (_channelState == null)
+ _channelState = new EventChannelState();
+ return _channelState.ParseCommand(name, value);
+ }
+ }
+
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceIn.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,6 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventPresenceIn : EventPresence
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceOut.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,8 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventPresenceOut : EventPresence
+ {
+
+
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceProbe.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventPresenceProbe.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket.SipEvents
+{
+ class EventPresenceProbe : EventPresence
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventRoster.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventRoster.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace FreeSwitch.EventSocket
+{
+ class EventRoster : SipEvent
+ {
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaExpire.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaExpire.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,63 @@
+namespace FreeSwitch.EventSocket
+{
+ public class EventSofiaExpire : EventPresence
+ {
+ private string _profileName;
+ private string _userName;
+ private string _domain;
+ private string _userAgent;
+
+ public string ProfileName
+ {
+ get { return _profileName; }
+ set { _profileName = value; }
+ }
+
+ public string UserName
+ {
+ get { return _userName; }
+ set { _userName = value; }
+ }
+
+ public string Domain
+ {
+ get { return _domain; }
+ set { _domain = value; }
+ }
+
+ public string UserAgent
+ {
+ get { return _userAgent; }
+ set { _userAgent = value; }
+ }
+
+ /*
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile-name", "%s", argv[6]);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "user", "%s", argv[1]);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "host", "%s", argv[2]);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "user-agent", "%s", argv[5]);
+ * */
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "profile-name":
+ _profileName = value;
+ break;
+ case "user":
+ _userName = value;
+ break;
+ case "host":
+ _domain = value;
+ break;
+ case "user-agent":
+ _userAgent = value;
+ break;
+ default:
+ return base.ParseCommand(name, value);
+ }
+ return true;
+
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaRegister.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/EventSofiaRegister.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,92 @@
+namespace FreeSwitch.EventSocket
+{
+ /*
+ * profile-name: gauffin.com
+from-user: jonas
+from-host: gauffin.com
+contact: %22Jonas%20Gauffin%22%20%3Csip%3Ajonas%40192.168.1.101%3A5060%3E
+*/
+
+ /// <summary>
+ /// Sofia_reg.c way down in sofia_reg_handle_register
+ /// </summary>
+ public class EventSofiaRegister : EventBase
+ {
+ private string _domain;
+ private string _profileName;
+ private string _user;
+ private string _contact;
+ private string _callId;
+ private int _expires;
+
+ public string ProfileName
+ {
+ get { return _profileName; }
+ set { _profileName = value; }
+ }
+
+ public string UserName
+ {
+ get { return _user; }
+ set { _user = value; }
+ }
+
+ public string Domain
+ {
+ get { return _domain; }
+ set { _domain = value; }
+ }
+
+ public string Contact
+ {
+ get { return _contact; }
+ set { _contact = value; }
+ }
+
+ public string CallId
+ {
+ get { return _callId; }
+ set { _callId = value; }
+ }
+
+ public int Expires
+ {
+ get { return _expires; }
+ set { _expires = value; }
+ }
+
+ /*
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "profile-name", "%s", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-user", "%s", to_user);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from-host", "%s", to_host);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "rpid", "%s", rpid);
+ */
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "profile-name":
+ _profileName = value;
+ break;
+ case "from-user":
+ _user = value;
+ break;
+ case "from-host":
+ _domain = value;
+ break;
+ case "contact":
+ _contact = value;
+ break;
+ case "call-id":
+ _callId = value;
+ break;
+ case "expires":
+ int.TryParse(value, out _expires);
+ break;
+ default:
+ return base.ParseCommand(name, value);
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/SipEvent.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/SipEvents/SipEvent.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,39 @@
+namespace FreeSwitch.EventSocket
+{
+ public class SipEvent : EventBase
+ {
+ private string _from;
+ private string _protocol;
+
+ public string Protocol
+ {
+ get { return _protocol; }
+ set { _protocol = value; }
+ }
+
+ /// <summary>
+ /// username@domain
+ /// </summary>
+ public string From
+ {
+ get { return _from; }
+ set { _from = value; }
+ }
+
+ public override bool ParseCommand(string name, string value)
+ {
+ switch (name)
+ {
+ case "from":
+ _from = value;
+ break;
+ case "proto":
+ _protocol = value;
+ break;
+ default:
+ return base.ParseCommand(name, value);
+ }
+ return true;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringHelper.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringHelper.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,55 @@
+namespace FreeSwitch.EventSocket
+{
+ public static class StringHelper
+ {
+ /// <summary>
+ /// This method converts a enum value to the correct format
+ /// that FreeSwitch uses (WORD1_WORD2) instead of the CamelCase that
+ /// we use in .net.
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
+ public static string UpperCaseToCamelCase(string name)
+ {
+ bool isFirst = true;
+ string result = string.Empty;
+ foreach (char ch in name)
+ {
+ if (isFirst)
+ {
+ result += char.ToUpper(ch);
+ isFirst = false;
+ }
+ else
+ {
+ if (ch == '_')
+ isFirst = true;
+ else
+ result += char.ToLower(ch);
+ }
+ }
+ return result;
+ }
+
+ public static string CamelCaseToUpperCase(string name)
+ {
+ string result = string.Empty;
+ bool isFirst = true;
+ foreach (char ch in name)
+ {
+ if (char.IsUpper(ch))
+ {
+ if (!isFirst)
+ result += '_';
+ else
+ isFirst = false;
+ result += char.ToUpper(ch);
+ }
+ else
+ result += char.ToUpper(ch);
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringParser.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/FreeSwitchEventSocket/StringParser.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,269 @@
+using System.Collections.Generic;
+
+namespace EventSocketParser
+{
+ internal class StringParser
+ {
+ private readonly Stack<int> _savedPositions = new Stack<int>();
+ private int _pos;
+ private string _text;
+
+ public StringParser(string text)
+ {
+ _pos = 0;
+ _text = text;
+ }
+
+ public bool EOF
+ {
+ get { return IsEOF(_pos); }
+ }
+
+ /// <summary>
+ /// true if we are currently on a emty line
+ /// </summary>
+ public bool EOL
+ {
+ get
+ {
+ if (EOF)
+ return false;
+ else if (_text[_pos] == '\n')
+ return true;
+ else if (_pos < _text.Length - 2)
+ return _text[_pos] == '\r' && _text[_pos + 1] == '\n';
+ else
+ return false;
+ }
+ }
+
+ public void SavePos()
+ {
+ _savedPositions.Push(_pos);
+ }
+
+ public void RestorePos()
+ {
+ _pos = _savedPositions.Pop();
+ }
+
+ public void RemoveSavedPos()
+ {
+ _savedPositions.Pop();
+ }
+
+ public void ClearSavedPositions()
+ {
+ _savedPositions.Clear();
+ }
+
+ private bool IsEOF(int pos)
+ {
+ return pos >= _text.Length - 1;
+ }
+
+ public bool IsEmptyLine(bool skipWhitespaces)
+ {
+ if (EOF)
+ return false;
+ else if (_pos == _text.Length - 1)
+ return _text[_pos] == '\n';
+ else
+ return _text[_pos] == '\r' && _text[_pos + 1] == '\n';
+ }
+
+ public string PeekWord(bool skipWS, bool stopAtEOL)
+ {
+ int startpos = _pos;
+ if (skipWS)
+ SkipWS();
+ int pos = FindWS(stopAtEOL);
+ _pos = startpos;
+
+ if (pos != -1)
+ return _text.Substring(_pos, pos - _pos);
+ else
+ return string.Empty;
+ }
+
+ public string GetWord(bool skipWS, bool stopAtEOL)
+ {
+ int startpos = _pos;
+ if (skipWS)
+ SkipWS();
+ int pos = FindWS(stopAtEOL);
+
+ _pos = pos;
+
+ if (pos != -1)
+ return _text.Substring(startpos, pos - startpos);
+ else
+ return string.Empty;
+ }
+
+ public string ReadLine()
+ {
+ return ReadLine(false);
+ }
+
+ public string ReadLine(bool trimWhiteSpaces)
+ {
+ if (EOF)
+ return string.Empty;
+
+ if (trimWhiteSpaces)
+ SkipWS();
+
+ // loop until we get new line chars
+ int startpos = _pos;
+ while (!EOF && !IsEOL())
+ ++_pos;
+
+ // Save _pos, trim whitespaces, restore _pos
+ int pos = _pos;
+ if (trimWhiteSpaces)
+ TrimEnd();
+ int endpos = _pos;
+ _pos = pos;
+
+ // Move to after new line chars
+ if (_text[_pos] == '\r')
+ _pos += 2;
+ else
+ ++_pos;
+
+ // .. and the result is line without whitespaces at the end and without new line chars.
+ return _text.Substring(startpos, endpos - startpos);
+ }
+
+ public string ReadToEmptyLine()
+ {
+ int chars = 4;
+ int pos = _text.IndexOf("\n\n", _pos);
+ if (pos == -1)
+ {
+ chars = 2;
+ pos = _text.IndexOf("\n\n", _pos);
+ }
+ if (pos == -1)
+ return string.Empty;
+
+ int startpos = _pos;
+ _pos = pos + chars;
+ return _text.Substring(startpos, pos - startpos);
+ }
+
+ public string Read(int chars)
+ {
+ if (_text.Length - _pos < chars)
+ return string.Empty;
+
+ string result = _text.Substring(_pos, chars);
+ _pos += chars;
+ return result;
+ }
+
+ public string ReadToEnd()
+ {
+ string result = _text.Substring(_pos, _text.Length - _pos);
+ _pos = _text.Length;
+ return result;
+ }
+
+ public string Read(char delimiter, bool skipWS)
+ {
+ if (skipWS)
+ SkipWS();
+
+ // find delimiter
+ int startpos = _pos;
+ while (!EOF && _text[_pos] != delimiter)
+ ++_pos;
+
+ // did not find it, reset pos
+ if (EOF)
+ {
+ _pos = startpos;
+ return string.Empty;
+ }
+ else
+ {
+ ++_pos; // skip delimiter
+ int endpos = TrimEnd(); // skip
+ return _text.Substring(startpos, endpos - startpos);
+ }
+ }
+
+ private int TrimEnd()
+ {
+ int pos = _pos;
+ while (IsWS(_text[pos]))
+ --pos;
+ return pos;
+ }
+
+ private int FindWS(bool stopAtEOL)
+ {
+ if (!stopAtEOL)
+ return FindWS();
+
+ int pos = _pos;
+ while (!IsEOF(pos) && !IsEOL(_text[pos]) && !IsWS(_text[pos]))
+ ++pos;
+
+ return IsEOF(pos) ? -1 : pos;
+ }
+
+ private bool IsEOL()
+ {
+ if (_text[_pos] == '\r' && _text[_pos + 1] == '\n')
+ return true;
+ else if (_text[_pos] == '\n')
+ return true;
+ else
+ return false;
+ }
+
+ private bool IsEOL(char ch)
+ {
+ return ch == '\r' || ch == '\n';
+ }
+
+ private bool IsWS(char ch)
+ {
+ return ch == '\t' || ch == ' ';
+ }
+
+ private int FindWS()
+ {
+ int pos = _pos;
+ while (!IsEOF(pos) && !IsWS(_text[pos]))
+ ++pos;
+
+ return IsEOF(pos) ? -1 : pos;
+ }
+
+ public void SkipWS()
+ {
+ while (!EOF && IsWS(_text[_pos]))
+ ++_pos;
+ }
+
+ public void RemoveUsedContent()
+ {
+ _text = _text.Remove(0, _pos);
+ _pos = 0;
+ }
+
+ public void Append(string value)
+ {
+ _text += value;
+ }
+
+ public void Clear()
+ {
+ _text = string.Empty;
+ _pos = 0;
+ }
+ }
+}
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/IvrSocket.csproj
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/IvrSocket.csproj Thu May 1 14:27:39 2008
@@ -0,0 +1,54 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{22F26D13-0A0E-4345-9FEC-CE13FC8F37FD}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>IvrSocket</RootNamespace>
+ <AssemblyName>IvrSocket</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Voicemail.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\FreeSwitchEventSocket\FreeSwitch.EventSocket.csproj">
+ <Project>{3F8895F6-F710-4323-B96A-4EFB6BC97E08}</Project>
+ <Name>FreeSwitch.EventSocket</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Program.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,38 @@
+using System;
+using FreeSwitch.EventSocket;
+
+namespace IvrSocket
+{
+ class Program
+ {
+ private static EventManager mgr;
+ static void Main(string[] args)
+ {
+ mgr = new EventManager();
+ mgr.EventReceived += IvrManager;
+ mgr.Subscribe(Event.All);
+ mgr.Start("localhost");
+ Console.ReadLine();
+ }
+
+ private static void IvrManager(EventBase receivedEvent)
+ {
+ Console.WriteLine(receivedEvent.Name);
+ if (receivedEvent is ChannelEvent)
+ {
+ ChannelEvent evt = (ChannelEvent) receivedEvent;
+ Console.WriteLine(evt.Name + ": " + evt.UniqueId);
+ }
+ if (receivedEvent is EventChannelAnswer)
+ {
+ EventChannelAnswer answer = (EventChannelAnswer)receivedEvent;
+ if (answer.Parameters["variable_ivr_name"] == "voicemail")
+ new Voicemail(mgr, answer.UniqueId);
+ }
+ else if (receivedEvent is EventChannelHangup)
+ {
+ Console.WriteLine("Bye bye baby!");
+ }
+ }
+ }
+}
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Properties/AssemblyInfo.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("IvrSocket")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("IvrSocket")]
+[assembly: AssemblyCopyright("Copyright © 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("3e447189-bfd8-4412-93bb-da3543dd2ca6")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs
==============================================================================
--- (empty file)
+++ freeswitch/trunk/scripts/contrib/verifier/EventSocket/trunk/IvrSocket/Voicemail.cs Thu May 1 14:27:39 2008
@@ -0,0 +1,28 @@
+using System;
+using System.Threading;
+using FreeSwitch.EventSocket;
+using FreeSwitch.EventSocket.Ivr;
+
+namespace IvrSocket
+{
+ /// <summary>
+ /// Very simple voicemail app =)
+ /// </summary>
+ class Voicemail
+ {
+ private readonly IvrInterface _ivr;
+
+ public Voicemail(EventManager mgr, string uuid)
+ {
+ _ivr = new IvrInterface(mgr, uuid);
+ _ivr.BeginInvoke(OnIvr, null, null);
+ }
+
+ private void OnIvr(IvrInterface app)
+ {
+ _ivr.Play("sv\\system\\record_after_beep.wav", IvrInterface.AllDigits);
+ //_ivr.Sleep(5000);
+ //_ivr.Record("voicemails\\" + Guid.NewGuid() + ".wav", 60);
+ }
+ }
+}
1
0