Wednesday, March 15, 2006

Forwarding lines with ATAPI.NET is simple and easy (assuming, of course, that the underlying TSP supports it).

The first step is knowing whether a given line device even supports forwarding.  This is trivial:

TapiManager mgr = new TapiManager("ForwardingTest");

foreach (TapiLine line in mgr.Lines)
{
   
if
(line.Capabilities.SupportsForwarding)
   {
      Console.WriteLine("Line {0} supports forwarding!"
, line.Name);
   }
}

Once we've identified a specific line, we can look at each address and get more information such as the types of forwarding supported.  For example, we might be able to forward to different numbers based on specific conditions such as whether the call goes unanswered vs. whether the address is in use and returning a busy signal.  We might also be able to forward specific inbound callers (very useful to get rid of your bosses calls).  We can get this information from the Capabilities of the TapiAddress object:

foreach (TapiAddress addr in line.Addresses)
{
   
Console.WriteLine("Forwarding modes supported on {0} are {1}"
, addr.Address, addr.Capabilities.SupportedForwardingModes);
}

We can also retrieve any existing forwarding information through the Status of the TapiAddress:

foreach (ForwardInfo fwd in addr.Status.ForwardingInformatioin)
   
Console.WriteLine("\t{0} to {1}:{2}"
, fwd.ForwardMode, fwd.DestinationAddressType, fwd.DestinationAddress);

This outputs: "Unconditional to PhoneNumber:1234" on a forwarded line I setup.

Finally, the big question is how to change the forwarding information, this is pretty easy as well.  You can set forwarding information on two levels, the entire line (which impacts all addresses), or a specific address.  This is done through two methods present on both TapiAddress and TapiLine which are Forward and CancelForward.  So, to cancel all forwarding in effect on every line we could do the following:

Console.WriteLine("Canceling all forwards:");
foreach (TapiLine line in
mgr.Lines)
{
   
if
(line.Capabilities.SupportsForwarding)
   {
      
try
      
{
         line.CancelForward();
      }
      
catch (TapiException
ex)
      {
         
Console.WriteLine("{0} - {1}"
, line, ex.Message);
      }
   }
}

Or, to setup the forwarding as above, I can issue a call to the Forward method:

ForwardInfo[] fwdInfo = new ForwardInfo[] {
      
new ForwardInfo(ForwardingMode.Unconditional, 0, "1234"
)
};

foreach (TapiLine line in mgr.Lines)
{
   
if
(line.Capabilities.SupportsForwarding)
   {
      
try
      
{
         line.Forward(fwdInfo, 5,
null
);
      }
      
catch (TapiException
ex)
      {
         
Console.WriteLine("{0} - {1}"
, line.Name, ex.Message);
      }
   }
}

The ForwardInfo class describes a single forwarding instruction and you pass an array of these info the Forward method to indicate how things are to be managed.  Exceptions need to be handled because the TAPI service provider might not allow the particular forwarding at this point in time, or the destination might not be allowed, etc.

Under the covers this will issue a lineForward request with a LINEFORWARDLIST setup for each of the ForwardInfo structures.

That about covers it!  Ping me with any questions if you want.

 

posted on 3/15/2006 2:43:58 PM (Central Standard Time, UTC-06:00)  #   

Related Posts:
Implementing Drag/Drop with TabControl
ATAPI assembly updated!
Creating Extensible Applications with MAF (System.AddIn)
Guerrilla .NET Tampa samples
TSP++ 3.0 is now free!
Adding Pause/Resume into SynchronizationContext based components

Tracked by:
"4839_architectonic - Departurebanish.com" (4839_architectonic - Departurebanish... [Trackback]
"backsoon" (backsoon) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"halifest" (halifest) [Trackback]
"Running The Guard... NYHC" (Running The Guard... NYHC) [Trackback]
"Galaxy Portfolio Services" (Galaxy Portfolio Services) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"Socialist Appeal" (Socialist Appeal) [Trackback]
http://www.setfirestudios.com/work.php [Trackback]
"fuck that, fuck them, fuck everyone else." (fuck that, fuck them, fuck everyone... [Trackback]
http://www.setfirestudios.com/main.php [Trackback]
"Over N Out. :: Index" (Over N Out. :: Index) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"Baylor - Departurebanish.com" (Baylor - Departurebanish.com) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"Departurebanish.com" (Departurebanish.com) [Trackback]
"CHARA. reppin' pei" (CHARA. reppin' pei) [Trackback]
"4 < 9" (4 < 9) [Trackback]
"AlloyMail" (AlloyMail) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"Non-party - Departurebanish.com" (Non-party - Departurebanish.com) [Trackback]
"2029_guiftes - Departurebanish.com" (2029_guiftes - Departurebanish.com) [Trackback]
"Deutsche Lebens Rettungs Gesellschaft eV (DLRG)" (Deutsche Lebens Rettungs Gese... [Trackback]
"Bus Pass" (Bus Pass) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"She Kills dot com bitches." (She Kills dot com bitches.) [Trackback]
"8533 - Departurebanish.com" (8533 - Departurebanish.com) [Trackback]
"Camera Whores!!!" (Camera Whores!!!) [Trackback]
"Athenian_622 - Departurebanish.com" (Athenian_622 - Departurebanish.com) [Trackback]
"Untitled Document" (Untitled Document) [Trackback]
"Visual Elements: The Alkaline Earth Metals" (Visual Elements: The Alkaline Eart... [Trackback]
"Erica Funghi Snc" (Erica Funghi Snc) [Trackback]
"1471 - Departurebanish.com" (1471 - Departurebanish.com) [Trackback]
"Circumstances_8558 - Departurebanish.com" (Circumstances_8558 - Departurebanish... [Trackback]
http://www.setfirestudios.com/contacts.php [Trackback]
"Suggestion_2469 - Departurebanish.com" (Suggestion_2469 - Departurebanish.com) [Trackback]
"kodak camers" (kodak camers) [Trackback]
"lake shafer boat rentals indiana" (lake shafer boat rentals indiana) [Trackback]
"unicorn tattoo" (unicorn tattoo) [Trackback]
"cellphone pictures" (cellphone pictures) [Trackback]
"Curling Shampoo" (Curling Shampoo) [Trackback]
"active mixer device%2C computer volume" (active mixer device%2C computer volume... [Trackback]
"nude tv" (nude tv) [Trackback]
"cheap digital camera" (cheap digital camera) [Trackback]
"prozac phentermine combination July 2005" (prozac phentermine combination July ... [Trackback]
"porn name generator" (porn name generator) [Trackback]
"African American Chefs" (African American Chefs) [Trackback]
"elettrostimolatori tesmed" (elettrostimolatori tesmed) [Trackback]
"help desk it software" (help desk it software) [Trackback]
"letter to creditor bankruptcy alternative" (letter to creditor bankruptcy alter... [Trackback]
"early heart attack symptoms" (early heart attack symptoms) [Trackback]
"Hear Pager Tones Fire" (Hear Pager Tones Fire) [Trackback]
"dmae powder" (dmae powder) [Trackback]