Programming Model Example

The following sections discuss the ez_console sample application included with the EZTapiAPI SDK. This is a Win32 console application designed to demonstrate the EZTapiAPI library interface. This program is actually two demo applications in one.


Synchronous Programming Model
Asynchronous Programming Model
ez_console Demo Source Code



Synchronous Programming Model


On startup of the ez_console application, the EZTapiAPI engine is initialized and a single EZLine device is opened. The EZLine device will be in the EZ_CALLSTATE_ONHOOK state after it has been successfully opened.

A menu is then presented to the user allowing the user to issue keyboard commands for placing or answering calls. Once a valid call has been established, the user can then issue keyboard commands to play, and record prompts, send and collect DTMF digits, and perform other call related tasks.

All EZTapiAPI function calls resulting from user input are made synchronously. EZTapiAPI functions are called synchronously by specifying an EZCallType value of EZ_SYNC.


Return to Top



Asynchronous Programming Model


As mentioned above, on startup of the ez_console application, the EZTapiAPI engine is initialized, and a single EZLine device is opened. The EZLine device will be in the EZ_CALLSTATE_ONHOOK state after it has been successfully opened.

Since a valid callback function pointer is specified in the call to EZTapiInitialize, the application is able to receive event notifications. If no user input in provided through the keyboard interface, this application will work as an answering machine after receiving four EZ_RING_EVENTS.

The application issues asynchronous EZTapiAPI function calls to answer the incoming call, play a voice prompt and then record a voice message. All functions are executed based on completion events received for the EZLine device. Completion events are posted for all functions called with an EZCallType value of EZ_ASYNC.


Return to Top



ez_console Demo Source Code


// System Include files
#include <stdio.h>
#include <windows.h>

// EZTapiAPI include files
#include "ezparams.h"
#include "ezerrors.h"
#include "eztapiapi.h"


enum
{
   TASK_MAKECALL,
   TASK_WAITFORCALL,
   TASK_ANSWERCALL,
   TASK_PLAYPROMPT,
   TASK_RECORDPROMPT,
   TASK_SENDDIGITS,
   TASK_COLLECTDIGITS,
   TASK_HANGUPCALL,
   TASK_GETCALLSTATE,
   TASK_QUIT,
   TASK_INVALIDENTRY
} CALL_TASK;


/******************************************************************************
  Function: ProcessEZError()

  Description: The following function simply identifies a particular error and
               prints the defined error in text form to standard out.

  Parameters: error_num -- the numeric error identifier

  Return Values: <none>
*******************************************************************************/
void ProcessEZError(LONG error_num)
{
    switch (error_num)
    {
       case EZ_EVENTMGMT_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_EVENTMGMT_ERROR.\n", error_num);
          break;

       case EZ_HANGUP_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_HANGUP_ERROR.\n", error_num);
          break;

       case EZ_BADFORMAT_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_BADFORMAT_ERROR.\n", error_num);
          break;

       case EZ_FILENOTFOUND_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_FILENOTFOUND_ERROR.\n", error_num);
          break;

       case EZ_BEEP_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_BEEP_ERROR.\n", error_num);
          break;

       case EZ_PARAM_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_PARAM_ERROR.\n", error_num);
          break;

       case EZ_MEMORY_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_MEMORY_ERROR.\n", error_num);
          break;
       case EZ_RESOURCE_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_RESOURCE_ERROR.\n", error_num);
          break;

       case EZ_TIMEOUT_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_TIMEOUT_ERROR.\n", error_num);
          break;

       case EZ_NOTSP_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_NOTSP_ERROR.\n", error_num);
          break;

       case EZ_CALLBUSY_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_CALLBUSY_ERROR.\n", error_num);
          break;
       case EZ_CALLNOANSWER_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_CALLNOANSWER_ERROR.\n", error_num);
          break;

       case EZ_CALLSTATE_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_CALLSTATE_ERROR.\n", error_num);
          break;

       case EZ_TAPIVERSION_ERROR:

          printf("ERROR: EZ_ERROR: %d == EZ_TAPIVERSION_ERROR.\n", error_num);
          break;

       default:

          printf("ERROR: Unknown EZ_ERROR: %d.\n", error_num);
          break;

    } // end switch()

    return;
}

/******************************************************************************
  Function: ez_callback()

  Description: EZTapiAPI callback function, which is needed to handle
               asynchronous EZTapiAPI function calls. The EZTapiAPI engine
               signals EZLine events and errors back to the client application
               via this mechanism.

  Parameters: aLine -- line on which an event occurred
              EZEvent -- event which caused callback function to be called.
              ezdata -- pointer to some data associated with the EZEvent.
              usrData -- user defined data pointer

  Return Values: <none>
*******************************************************************************/
void ez_callback(EZLine aLine, EZ_EVENT EZEvent, VOID *ezdata, VOID *usrData)
{
    LONG rc;
    DWORD *appData;
    static DWORD tot_rings = 0;
    EZCallInfo *pCallInfo = NULL;
    char szDigits[EZ_DIGITBUFFERSIZE];
    char szFileName[EZ_MAXPATHSIZE];
    EZWaveFormat waveFmt;

    /**********************************************************************
     Cast the VOID pointer usrData, to its appropriate type. Here simply
     casting to a DWORD pointer, then checking to make sure value was
     received correctly.
    ***********************************************************************/
    appData = (DWORD *) usrData;
    if (*appData != -999)
       printf("ERROR: ez_callback called with incorrect appData value.\n");

    switch (EZEvent)
    {
       case EZ_RING_EVENT:

          printf("INFO: ez_callback received EZ_RING_EVENT.\n");

          tot_rings += 1;

          if (tot_rings == 4)
          {
             /**************************************************************
             Phoneline has received 4 rings. Assume no one is available
             to answer the call. Answer the call to take a message.
             ***************************************************************/
             printf("INFO: Calling EZAnswerCall().\n");

             rc = EZAnswerCall(aLine, EZ_ASYNC);
             if (rc != EZ_SUCCESS)
             {
                printf("ERROR: An error occurred calling EZAnswerCall().\n");
                ProcessEZError(rc);
             }

          } // if (tot_rings == 4)

          break;

       case EZ_CALLCONNECT_EVENT:

          printf("INFO: ez_callback received EZ_CALLCONNECT_EVENT.\n");
          break;

       case EZ_CALLBUSY_EVENT:

          printf("INFO: ez_callback received EZ_CALLBUSY_EVENT.\n");
          break;

       case EZ_CALLERID_EVENT:

          printf("INFO: ez_callback received EZ_CALLERID_EVENT.\n");

          /******************************************************************
           Cast the VOID *ezdata value to a EZCallInfo structure to retrieve
           Caller ID information.
          *******************************************************************/
          pCallInfo = (EZCallInfo *) ezdata;

          printf("INFO: Caller Name: %s, Caller Number: %s.\n", pCallInfo->CallerName, pCallInfo->CallerNumber);
          break;

       case EZ_CALLANSWER_EVENT:

          printf("INFO: ez_callback received EZ_CALLANSWER_EVENT.\n");

          tot_rings = 0;

          printf("INFO: Calling EZPlayPrompt().\n");

          rc = EZPlayPrompt(aLine, "nobodyhome.wav", EZ_ASYNC);
          if (rc != EZ_SUCCESS)
          {
             printf("ERROR: An error occurred calling EZPlayPrompt().\n");
             ProcessEZError(rc);
          }

          break;

       case EZ_CALLHANGUP_EVENT:

          printf("INFO: ez_callback received EZ_CALLHANGUP_EVENT.\n");

          tot_rings = 0;

          printf("INFO: Calling EZHangupCall().\n");

          rc = EZHangupCall(aLine);
          if (rc != EZ_SUCCESS)
          {
             printf("ERROR: An error occurred calling EZHangupCall().\n");
             ProcessEZError(rc);
          }
          else
          {
             printf("INFO: EZHangupCall() successful.\n\n");
          }

          break;

       case EZ_PLAYBEGIN_EVENT:

          printf("INFO: ez_callback received EZ_PLAYBEGIN_EVENT.\n");
          break;

       case EZ_PLAYSTOP_EVENT:
       case EZ_PLAYEND_EVENT:

          if (EZEvent == EZ_PLAYSTOP_EVENT)
             printf("INFO: ez_callback received EZ_PLAYSTOP_EVENT.\n");
          else
             printf("INFO: ez_callback received EZ_PLAYEND_EVENT.\n");

             /******************************************************************
              Set EZWaveFormat to record an 8000Khz, 16 bits/sample, mono wave
              file recording.
             *******************************************************************/
             waveFmt.NumChannels = 1;
             waveFmt.SampleRate = 8000;
             waveFmt.BitsPerSample = 16;

             printf("INFO: Calling EZRecordPrompt().\n");

             /******************************************************************
              Calling EZRecordPrompt() with empty szFileName. EZTapi will create
              a unique filename from the computer date and time.
             *******************************************************************/
             rc = EZRecordPrompt(aLine, NULL, NULL, &waveFmt, true, EZ_ASYNC);
             if (rc != EZ_SUCCESS)
             {
                printf("ERROR: An error occurred calling EZRecordPrompt().\n");
                ProcessEZError(rc);
             }

             break;

       case EZ_RECORDBEGIN_EVENT:

          printf("INFO: ez_callback received EZ_RECORDBEGIN_EVENT.\n");
          break;

       case EZ_RECORDSTOP_EVENT:
       case EZ_RECORDEND_EVENT:

          if (EZEvent == EZ_RECORDSTOP_EVENT)
             printf("INFO: ez_callback received EZ_RECORDSTOP_EVENT.\n");
          else
             printf("INFO: ez_callback received EZ_RECORDEND_EVENT.\n");

          /******************************************************************
           Cast parameter 3 of ez_callback() to get name of recording file.
          *******************************************************************/
          strcpy(szFileName, (char *) ezdata);

          printf("INFO: New wave file recording: %s.\n", szFileName);

          break;

       case EZ_COLLECTDIGITBEGIN_EVENT:

          printf("INFO: ez_callback received EZ_COLLECTDIGITBEGIN_EVENT.\n");
          break;

       case EZ_COLLECTDIGITTIMEOUT_EVENT:
       case EZ_COLLECTDIGITSTOP_EVENT:
       case EZ_COLLECTDIGITEND_EVENT:

          if (EZEvent == EZ_COLLECTDIGITTIMEOUT_EVENT)
             printf("INFO: ez_callback received EZ_COLLECTDIGITTIMEOUT_EVENT.\n");
          else if (EZEvent == EZ_COLLECTDIGITSTOP_EVENT)
             printf("INFO: ez_callback received EZ_COLLECTDIGITSTOP_EVENT.\n");
          else
             printf("INFO: ez_callback received EZ_COLLECTDIGITEND_EVENT.\n");

          /******************************************************************
           Cast parameter 3 of ez_callback() to get any collected digits.
          *******************************************************************/
          strcpy(szDigits, (char *) ezdata);

          printf("INFO: EZCollectDigits() done. Received Digit String: %s\n", szDigits);

          printf("INFO: Calling EZFlushDigitBuffer().\n");

          rc = EZFlushDigitBuffer(aLine);
          if (rc != EZ_SUCCESS)
          {
             printf("ERROR: An error occurred calling EZFlushDigitBuffer.\n");
             ProcessEZError(rc);
          }
          else
          {
             printf("INFO: EZFlushDigitBuffer() completed successfully.\n");
          }

          break;

       case EZ_SENDDIGITBEGIN_EVENT:

          printf("INFO: ez_callback received EZ_SENDDIGITBEGIN_EVENT.\n");
          break;

       case EZ_SENDDIGITSTOP_EVENT:

          printf("INFO: ez_callback recevied EZ_SENDDIGITSTOP_EVENT.\n");
          break;

       case EZ_SENDDIGITEND_EVENT:

          printf("INFO: ez_callback recevied EZ_SENDDIGITEND_EVENT.\n");
          break;

       case EZ_UNEXPECTED_EVENT:

          printf("WARNING: ez_callback received EZ_UNEXPECTED_EVENT.\n");
          break;

       default:

          printf("WARNING: ez_callback received unknown event. Unknown Event: 0x%x\n", EZEvent);
          break;

    } // end switch()

    return;

} // end ez_callback()

/******************************************************************************
  Function: GetNextTask()

  Description: The following function processes user input to decide the next
               call task to execute.

  Parameters: <none>

  Return Value: CALL_TASK constant
*******************************************************************************/
DWORD GetNextTask()
{
    char inputdata;
    DWORD CallTask;

    printf("\nINFO: Enter next call task to be performed.\n");

    inputdata = getchar();

    switch (inputdata)
    {
       case 'M':
       case 'm':

          CallTask = TASK_MAKECALL;

          break;

       case 'W':
       case 'w':

          CallTask = TASK_WAITFORCALL;
          break;

       case 'A':
       case 'a':

          CallTask = TASK_ANSWERCALL;
          break;

       case 'H':
       case 'h':

          CallTask = TASK_HANGUPCALL;
          break;

       case 'P':
       case 'p':

          CallTask = TASK_PLAYPROMPT;
          break;

       case 'R':
       case 'r':

          CallTask = TASK_RECORDPROMPT;
          break;

       case 'S':
       case 's':
          CallTask = TASK_SENDDIGITS;
          break;

       case 'C':
       case 'c':

          CallTask = TASK_COLLECTDIGITS;
          break;

       case 'G':
       case 'g':

          CallTask = TASK_GETCALLSTATE;
          break;

      
case 'U':
       case 'u':

          CallTask = TASK_UPDATEEZPARAM;
          break;

       case 'Q':
       case 'q':

          CallTask = TASK_QUIT;
          break;

       default:

          printf("\n\n\nERROR: Invalid menu selection.\n\n");
          printf("Enter:\n\n");
          printf(" 'M' or 'm' for TASK_MAKECALL.\n");
          printf(" 'W' or 'w' for TASK_WAITFORCALL.\n");
          printf(" 'H' or 'h' for TASK_HANGUPCALL.\n");
          printf(" 'P' or 'p' for TASK_PLAYPROMPT.\n");
          printf(" 'R' or 'r' for TASK_RECORDPROMPT.\n");
          printf(" 'S' or 's' for TASK_SENDDIGITS.\n");
          printf(" 'C' or 'c' for TASK_COLLECTDIGITS.\n");
          printf(" 'U' or 'u' for TASK_UPDATEEZPARAM.\n");
          printf(" 'Q' or 'q' for TASK_QUIT.\n\n");

          CallTask = TASK_INVALIDENTRY;

          break;

    } // end switch()

    // Remove trailing 'LF' character.
    inputdata = getchar();

    return(CallTask);
}

/******************************************************************************
  Function: main()   Description: Entry point for the EZTapiAPI driver application. A simple
               demo of EZTapiAPI functionality.

  Parameters: <none>
  Return Values: <none>
*******************************************************************************/
void main()
{
    LONG rc;
    DWORD dwNumEZLineDev;
    EZModemType ModemType;
    EZCallInfo callInfo;
    char szFileName[EZ_MAXPATHSIZE], szDigits[EZ_DIGITBUFFERSIZE];
    EZWaveFormat waveFmt;
    EZLine aLine;
    DWORD CurrCallTask;
    LONG userInfo = -999;
    DWORD i;
    DWORD dwCallState;

    printf("INFO: Calling EZInitializeTapi().\n");

    /**************************************************************************
     Initialize the EZTapiAPI Engine. This must be the first call by a client
     application to the EZTapiAPI library.
    ***************************************************************************/
    rc = EZTapiInitialize(EZ_CONSOLE_APP, &dwNumEZLineDev, (EZ_CALLBACK) &ez_callback, (void *) &userInfo);
    if (rc != EZ_SUCCESS)
    {
       printf("ERROR: An error occurred calling EZInitializeTapi(). EZTapiAPIError: %d.\n", rc);
       exit(1);
    }
    else
    {
       printf("INFO: Calling EZOpenLine().\n");

       /**********************************************************************
        Open a EZLine device.
       ***********************************************************************/
       rc = EZOpenLine(&aLine, EZ_OWNER, &ModemType);
       if (rc != EZ_SUCCESS)
       {
          printf("ERROR: An error occurred calling EZOpenLine().\n");
          ProcessError(rc);

          goto EZTAPI_FREE;
       }
       printf("INFO: Line %d, successfully opened.\n", aLine);

       printf("Enter:\n\n");
       printf("  'M' or 'm' for TASK_MAKECALL.\n");
       printf("  'W' or 'w' for TASK_WAITFORCALL.\n");
       printf("  'H' or 'h' for TASK_HANGUPCALL.\n");
       printf("  'P' or 'p' for TASK_PLAYPROMPT.\n");
       printf("  'R' or 'r' for TASK_RECORDPROMPT.\n");
       printf("  'S' or 's' for TASK_SENDDIGITS.\n");
       printf("  'C' or 'c' for TASK_COLLECTDIGITS.\n");
       printf("  'U' or 'u' for TASK_UPDATEEZPARAM.\n");
       printf("  'Q' or 'q' for TASK_QUIT.\n\n");

       while (true)
       {
          CurrCallTask = GetNextTask();

          switch (CurrCallTask)
          {
             case TASK_MAKECALL:

                printf("INFO: Calling EZMakeCall().\n");

                rc = EZMakeCall(aLine, "103", EZ_SYNC);
                if (rc != EZ_SUCCESS)
                {
                   printf("ERROR: An error occurred calling EZMakeCall().\n");
                   ProcessEZError(rc);
                }

                break;

             case TASK_WAITFORCALL:

                printf("INFO: Calling EZWaitForCall().\n");

                rc = EZWaitForCall(aLine, 1, &callInfo);
                if (rc != EZ_SUCCESS)
                {
                   printf("ERROR: An error occurred calling EZWaitForCall().\n");
                   ProcessError(rc);
                }

                break;

             case TASK_ANSWERCALL:

                 printf("INFO: Calling EZAnswerCall().\n");

                 rc = EZAnswerCall(aLine, EZ_SYNC);
                 if (rc != EZ_SUCCESS)
                 {
                    printf("ERROR: An error occurred calling EZAnswerCall.\n");
                    ProcessError(rc);
                 }

                 break;

             case TASK_PLAYPROMPT:

                printf("INFO: Calling EZPlayPrompt().\n");
                rc = EZPlayPrompt(aLine, "thankyou.wav", EZ_SYNC);
                if (rc != EZ_SUCCESS)
                {
                   printf("ERROR: An error occurred calling EZPlayPrompt().\n");
                   ProcessEZError(rc);
                }
                else
                {
                   printf("INFO: EZPlayPrompt() successful.\n");
                }

                break;

             case TASK_RECORDPROMPT:

                printf("INFO: Calling EZRecordPrompt().\n");
                waveFmt.NumChannels = 1;
                waveFmt.SampleRate = 8000;
                waveFmt.BitsPerSample = 16;

                memset(szFileName, '\0', EZ_MAXPATHSIZE);

                rc = EZRecordPrompt(aLine, szFileName, sizeof(szFileName), &waveFmt, true, EZ_SYNC);
                if (rc != EZ_SUCCESS)
                {
                   printf("ERROR: An error occurred calling EZRecordPrompt().\n");
                   ProcessEZError(rc);
                }
                else
                {
                   printf("INFO: EZRecordPrompt() successful.\n");
                   printf("INFO: New wave file recording: %s.\n", szFileName);
                }

                break;

             case TASK_SENDDIGITS:

                printf("INFO: Calling EZSendDigits().\n");

                rc = EZSendDigits(aLine, "!,102", EZ_SYNC);
                if (rc != EZ_SUCCESS)
                {
                   printf("ERROR: An error occurred calling EZSendDigits().\n");
                   ProcessEZError(rc);
                }
                else
                {
                   printf("INFO: EZSendDigits() successful.\n");
                }

                break;

             case TASK_COLLECTDIGITS:

                 memset(szDigits, '\0', EZ_DIGITBUFFERSIZE);

                 rc = EZCollectDigits(aLine, szDigits, 4, "#", EZ_SYNC);
                 if (rc != EZ_SUCCESS)
                 {
                    printf("ERROR: An error occurred calling EZCollectDigits().\n");
                    ProcessEZError(rc);
                 }
                 else
                 {
                    printf("INFO: EZCollectDigits() successful.\n");
                    printf("INFO: Digits collected: %s.\n", szDigits);
                 }

                 break;

             case TASK_HANGUPCALL:

                 printf("INFO: Calling EZHangupCall().\n");

                 rc = EZHangupCall(aLine);
                 if (rc != EZ_SUCCESS)
                 {
                    printf("ERROR: An error occurred calling EZHangupCall().\n");
                    ProcessEZError(rc);
                 }
                 else
                 {
                    printf("INFO: EZHangupCall() successful.\n\n");
                 }

                break;

             case TASK_GETCALLSTATE:

                printf("INFO: Calling EZGetCallState().\n");

                printf("INFO: EZCallState: %d.\n", EZGetCallState(aLine));

                break;

             case TASK_UPDATEEZPARAM:

                if (toggle)
                {
                   toggle = false;

                   rc = EZSetParameter(EZ_DIGITWAVESTOP_PARAM, 0);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_DIGITSTOP_PARAM set to FALSE.\n");
                   }

                   rc = EZSetParameter(EZ_FIRSTDIGITTIMEOUT_PARAM, 20000);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_FIRSTDIGITTIMEOUT_PARAM set to 20000 (20 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_INTERDIGITTIMEOUT_PARAM, 15000);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_INTERDIGITTIMEOUT_PARAM set to 15000 (15 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_RECORDHANGUPTRIM_PARAM, 5500);
                   if (rc != EZ_SUCCESS)
                   {                       printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_RECORDHANGUPTRIM_PARAM, set to 5500 (5.5 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_RECORDDIGITTRIM_PARAM, 1500);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_RECORDDIGITTRIM_PARAM, set to 1500 (1.5 seconds).\n");
                   }
                }
                else // Reset EZ_PARAMETERS back to their default values
                {
                   toggle = true;
                   rc = EZSetParameter(EZ_DIGITWAVESTOP_PARAM, 1);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_DIGITSTOP_PARAM set to TRUE.\n");
                   }

                   rc = EZSetParameter(EZ_FIRSTDIGITTIMEOUT_PARAM, 10000);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_FIRSTDIGITTIMEOUT_PARAM set to 10000 (10 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_INTERDIGITTIMEOUT_PARAM, 8000);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_INTERDIGITTIMEOUT_PARAM set to 8000 (8 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_RECORDHANGUPTRIM_PARAM, 0);
                   if (rc != EZ_SUCCESS)
                   {
                      printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_RECORDHANGUPTRIM_PARAM, set to 0 (0 seconds).\n");
                   }

                   rc = EZSetParameter(EZ_RECORDDIGITTRIM_PARAM, 0);
                   if (rc != EZ_SUCCESS)
                   {                       printf("ERROR: An error occurred calling EZSetEZTapiAPIParam().\n");
                      ProcessEZError(rc);
                   }
                   else
                   {
                      printf("INFO: EZ_RECORDDIGITTRIM_PARAM, set to 0 (0 seconds).\n");
                   }
                }

                break;

             case TASK_QUIT:

                printf("INFO: Quitting Application.\n");

                break;

             default:

                break;

          } // end switch(CurrCallTask)

          if (CurrCallTask == TASK_QUIT)
             break;

       } // end while (true)

    } // end if (EZInitializeTapi())

    printf("\n\n");

    /**************************************************************************
     Get the current callstate of this line to see if this phoneline is still
     connected.
    ***************************************************************************/
    dwCallState = EZGetCallState(aLine);
    if (dwCallState == EZ_CALLSTATE_CONNECTED)
    {
       printf("INFO: Calling EZHangupCall().\n");

       rc = EZHangupCall(aLine);
       if (rc != EZ_SUCCESS)
       {
          printf("ERROR: An error occurred calling EZHangupCall().\n");
          ProcessEZError(rc);
       }
       else
       {
          printf("INFO: EZHangupCall() successful.\n\n");
       }

    }

EZTAPI_FREE:

    printf("INFO: Calling EZLineClose().\n");

    rc = EZCloseLine(aLine);
    if (rc != EZ_SUCCESS)
    {
       printf("ERROR: An error occurred calling EZLineClose().\n");
       ProcessEZError(rc);
    }
    else
    {
       printf("INFO: EZLineClose() successful.\n");
    }

    printf("INFO: Calling EZTapiFree().\n");

    rc = EZTapiFree();
    if (rc != EZ_SUCCESS)
    {
       printf("ERROR: An error occurred calling EZTapiFree().\n");
       ProcessEZError(rc);
    }
    else
    {
       printf("INFO: EZTapiFree successful.\n");
    }

    printf("INFO: Exiting application....\n");

    return;

} // end main()

Return to Top



Copyright © 2003-2008,
PC Phone Connections. All rights reserved.