using System;
namespace AsterNET.Manager.Event
{
///
/// A NewCallerIdEvent is triggered when the caller id of a channel changes.
/// It is implemented in channel.c
///
public class NewCallerIdEvent : ManagerEvent
{
private int cidCallingPres;
private string cidCallingPresTxt;
public NewCallerIdEvent(ManagerConnection source)
: base(source)
{
}
///
/// Get/Set the new caller id.
///
public string CallerId { get; set; }
///
/// Get/Set the new Caller*ID Name if set or "≶Unknown>" if none has been set.
///
public string CallerIdName { get; set; }
///
/// Get/Set the new Caller*ID Numb.
///
public string CallerIdNum { get; set; }
///
/// Get the CallerId presentation/screening.
///
public int CidCallingPresNumeric
{
get { return cidCallingPres; }
}
///
/// Get/Sets the CallerId presentation/screening in the form "%d (%s)".
///
public string CidCallingPres
{
get { return cidCallingPres + " (" + cidCallingPresTxt + ")"; }
set
{
string s = value;
if (s == null || s.Length == 0)
return;
int spaceIdx = s.IndexOf(' ');
if (spaceIdx <= 0)
spaceIdx = s.Length;
try
{
cidCallingPres = int.Parse(s.Substring(0, spaceIdx));
}
catch (FormatException)
{
return;
}
if (s.Length > spaceIdx + 3)
cidCallingPresTxt = s.Substring(spaceIdx + 2, (s.Length - 1) - (spaceIdx + 2));
}
}
}
}