TeleTip #3: Sample Code to make a call
(Last modified: 20Jul1995)
This document (100188) is provided subject to the disclaimer at the end of this document.
Issue
TeleTip #3
"Where's the Code?"
Below is a sample program used to open a stream and make a call. Future Telephony Services API (TSAPI)sample programs will all be written to this same coding style to make it easier to read the comments, and more easily read the code.
/****************************************************************************
** File: MAKECALL.C
**
** Desc: Sample telephony program
**
** This NetWare Telephony Services program opens a stream,
** makes a call, and closes the stream.
**
** This program is written for Borland C 4.0 for Windows 3.1. It
** is compiled as an EASYWIN program, so that I didn't have to
** include all the Windows "overhead" code but can just get to
** the good stuff.
**
**
** Disclaimer
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** KVW Kevin V White Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 07-21-94 kvw First code.
** 07-22-94 kvw Added disclaimer
*/
/****************************************************************************
** Include headers, macros, function prototypes, etc.
*/
/*------------------------------------------------------------------------
** ANSI
*/
#include <stdio.h>
#include <string.h>
/*------------------------------------------------------------------------
** Windows
*/
#include <windows.h>
/*------------------------------------------------------------------------
** Telephony
*/
#include <acs.h>
#include <csta.h>
/****************************************************************************
** This function is the entire program, as it is very simple.
** Prompt user for input, open a stream, make a call, close the stream.
*/
void main(void)
{
/*------------------------------------------------------------------
** The following are defined for the first call, acsOpenStream
*/
ACSHandle_t acsHandle;
InvokeIDType_t invokeIDType;
InvokeID_t invokeID;
StreamType_t streamType;
ServerID_t serverID;
LoginID_t loginID;
Passwd_t passwd;
AppName_t applicationName;
Level_t acsLevelReq;
Version_t apiVer;
unsigned short sendQSize;
unsigned short sendExtraBufs;
unsigned short recvQSize;
unsigned short recvExtraBufs;
PrivateData_t *privateData;
RetCode_t rCode;
/*------------------------------------------------------------------
** The following are additional variables necessary for
** acsGetEventBlock
*/
CSTAEvent_t eventBuffer;
unsigned short eventBufferSize;
unsigned short numEvents;
/*------------------------------------------------------------------
** The following are for the cstaMakeCall
*/
DeviceID_t caller,callee;
/*------------------------------------------------------------------
** Miscellaneous variables
*/
short done=0;
/*------------------------------------------------------------------
** Setup parameters for call to open stream. Also, prompt user for
** input.
*/
invokeIDType=LIB_GEN_ID;
invokeID=0; /* don't need it, but set to zero anyway */
streamType=ST_CSTA; /* want to use csta functions */
strcpy(serverID,"ATT#G3_SWITCH#CSTA#PRV-NMS");
printf("\nEnter your user name:");
scanf("%s",loginID);
printf("\nEnter your password:");
scanf("%s",passwd);
printf("\nEnter your extension:");
scanf("%s",caller);
printf("\nEnter the extension you want to call:");
scanf("%s",callee);
strcpy(applicationName,"Simple App");
acsLevelReq=ACS_LEVEL1;
strcpy(apiVer,CSTA_API_VERSION);
sendQSize=0; /* default size queue*/
sendExtraBufs=0; /* use default number */
recvQSize=0; /* use default size */
recvExtraBufs=0; /* use default number */
privateData=NULL; /* no private data */
/*------------------------------------------------------------------
** Open the stream with above parameters
*/
rCode=acsOpenStream(&acsHandle,invokeIDType,invokeID,streamType,
serverID,loginID,passwd,applicationName,acsLevelReq,
apiVer,sendQSize,sendExtraBufs,recvQSize,recvExtraBufs,
privateData);
if (rCode < 0)
{
printf("acsOpenStream failure...");
return;
}
else
{
printf("acsOpenStream success\n");
invokeID=rCode;
}
/*------------------------------------------------------------------
** Block until the confirmation has been received that the stream
** was successfully opened. Just because NetWare returned the function
** code doesn't mean the stream has been opened yet.
*/
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(acsHandle,&eventBuffer,&eventBufferSize,
privateData,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType == ACS_OPEN_STREAM_CONF)
{
printf("ACS_OPEN_STREAM_CONF message has been received\n");
}
else
{
printf("event type is incorrect...");
return;
}
}
else
{
printf("acsGetEventBlock failure...");
return;
}
/*------------------------------------------------------------------
** Now that the stream has been successfully opened, go ahead and
** issue the make call function.
*/
rCode=cstaMakeCall(acsHandle,invokeID,caller,callee,
privateData);
/*------------------------------------------------------------------
** Now we need to poll for events until a confirmation has been
** received that the PBX has been able to make the call. Note that
** if something is invalid, the program will enter an infinite loop,
** as this simple program just sits and waits until a confirmation
** returns that is successful.
*/
while (!done)
{
rCode=acsGetEventPoll(acsHandle,&eventBuffer,&eventBufferSize,
privateData,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType == CSTA_MAKE_CALL_CONF)
{
printf("CSTA_MAKE_CALL_CONF message has been received\n");
done=1;
}
else
{
printf("event type is incorrect...");
}
}
}
/*------------------------------------------------------------------
** All done! Time to close the stream now.
*/
rCode=acsCloseStream(acsHandle,invokeID,privateData);
if (rCode < 0)
{
printf("acsCloseStream failure...");
return;
}
else
{
printf("acsCloseStream success\n");
}
return;
}
TIP: Use the code above as a template for making telephony programs. It contains the framework to which other function calls can be added.
document
Document Title: | TeleTip #3: Sample Code to make a call |
Document ID: | 100188 |
Creation Date: | 15Nov1994 |
Modified Date: | 20Jul1995 |
Revision: | 1 |
Novell Product Class: | NetWare |
disclaimer
The Origin of this information may be internal or external to Novell. Novell makes all reasonable efforts to verify this information. However, the information provided in this document is for your information only. Novell makes no explicit or implied claims to the validity of this information.
Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.