PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Principle
  • The different steps
  • Example
  • Example used to manage the incoming calls in the main thread
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Principle
The management of the incoming calls is performed in a specific "thread". When an incoming call is detected, the procedure associated with the thread is run. The management of the call is performed in this procedure.
The different steps
To manage the incoming calls in a WINDEV or WINDEV Mobile application:
  1. Define (if necessary) the TAPI device on which the calls must be detected. Use the functions:
    Versions 09 and later
    tapiCapability
    New in version 09
    tapiCapability
    tapiCapability
    Returns the characteristics of a telephony device.
    Versions 09 and later
    tapiDevice
    New in version 09
    tapiDevice
    tapiDevice
    Selects the TAPI device that will be used during the following telephony operations
    Versions 09 and later
    tapiDeviceList
    New in version 09
    tapiDeviceList
    tapiDeviceList
    Returns the list of TAPI 2.0-compatible devices installed on the current computer.
  2. Start the detection of incoming calls with tapiListen. This function runs a specific WLanguage procedure. This procedure will be automatically run when an incoming call is detected.
  3. In this procedure, you can:
    • find out the status of the call via the following constants:
      • tapiLineBusy: The line is currently busy.
      • tapiLineConnected: The line is connected.
      • tapiLineDialing: Dialing in progress.
      • tapiLineDialTone: The line gets a dial tone
      • tapiLineDisconnected: The correspondent has hung up
      • tapiLineProceeding: The call is dialed: searching for the correspondent
      • tapiLineRingBack: Ringing in progress
      • tapiNewCall: New call detected waiting for an answer or for a reject.
      • tapiCallInformation: The additional information (presentation of the number) is available. In most cases, this information will be available after the fist ring.
    • manage the call via the following functions:
      • finding out the characteristics of the incoming call:
        Versions 09 and later
        tapiCallDuring
        New in version 09
        tapiCallDuring
        tapiCallDuring
        Returns the duration of the call (difference between the start date and time of call and the end date and time of call).
        Versions 09 and later
        tapiCallEnd
        New in version 09
        tapiCallEnd
        tapiCallEnd
        Returns the date and time of the end of call.
        Versions 09 and later
        tapiCallerID
        New in version 09
        tapiCallerID
        tapiCallerID
        Used to find out the calling phone number (the one that calls).
        Versions 09 and later
        tapiCallIsOver
        New in version 09
        tapiCallIsOver
        tapiCallIsOver
        Used to find out whether the incoming or outgoing call is ended.
        Versions 09 and later
        tapiCallStart
        New in version 09
        tapiCallStart
        tapiCallStart
        Returns the date and time of the beginning of call (incoming or outgoing call).
      • perform specific operations:
        Versions 09 and later
        tapiAnswerCall
        New in version 09
        tapiAnswerCall
        tapiAnswerCall
        Answers an incoming call that was detected.
        Versions 09 and later
        tapiKeyPressed
        New in version 09
        tapiKeyPressed
        tapiKeyPressed
        Used to find out the history of the keys pressed on the phone keypad since the last call to tapiKeyPressed.
        Versions 09 and later
        tapiPlay
        New in version 09
        tapiPlay
        tapiPlay
        Plays a sound file (.WAV) for the specified line.
        Versions 09 and later
        tapiRecord
        New in version 09
        tapiRecord
        tapiRecord
        Saves the current communication in a .WAV file.
        Versions 09 and later
        tapiSendKey
        New in version 09
        tapiSendKey
        tapiSendKey
        Allows you to simulate the use of phone keys.
        Versions 09 and later
        tapiStop
        New in version 09
        tapiStop
        tapiStop
        Forces the reading of a pre-recorded message to stop (tapiPlay).

        Caution:
        This WLanguage procedure being run in a thread, all the constraints of the threads must be complied with (no window opening, no timer management, no event management, ...). See Managing threads with WINDEV for more details.
        We recommend that you limit the number of processes performed in this procedure. Indeed, during the duration of the call, the detection of the other calls (as well as all the telephony events) is frozen. If long processes must be performed, we advise you to process the call in the main thread of the application (see the example below).
  4. To end the session for detecting the incoming calls, use tapiStopCallDetection.
Example

Example used to manage the incoming calls in the main thread

  • Code for declaring the global variables of the window used for call detection. The different events used to manage the calls in the main thread of the application are declared in this code.
    GLOBAL
    gnEventID is int
    // Implement an event to manage the incoming calls in popup
    IF Event("DetectedCall", "*.*", "PhoneCall") = 0 THEN
    Error("Unable to manage the popup for call detection", ErrorInfo())
    END
    IF Event("EndDetectedCall", "*.*", "EndPhoneCall") = 0 THEN
    Error("Unable to manage the popup for call detection", ErrorInfo())
    END
    IF Event("DetectedCallIdentifier", "*.*", "PhoneCallInfo") = 0 THEN
    Error("Unable to manage the popup for call detection", ErrorInfo())
    END
  • Initialization code of window: this code is used to start the procedure for call detection.
    // Start the service for call detection
    IF tapiListen("IncomingCall", tapiOptionMediaModeFax, "CallDetection") THEN
    // The service for call detection is started
    Message("Call detection enabled")
    ELSE
    // The service for call detection is not started
     Error("Unable to start the call detection" + CR + ...
    "Error details:"+ CR + ErrorInfo(errMessage))
    END
  • Procedure for call detection:
    This procedure is used to detect the incoming calls.
    For each incoming call, the characteristics of the call are transmitted to the main thread by PostMessage.
    PROCÉDURE CallDetection(nServiceID, nCallID, nStatus)
    // WARNING:
    // The processes performed by this procedure are called from a thread
    // The display should be done via the main thread
    // (this is why PostMessage is used)
    // The "Trace" function must be used to debug this process
    // detection of incoming calls
    SWITCH nStatus
    // Detect a new call:
    // Note: Additional information will be available after the fist ring
    CASE tapiNewCall:
      // Signal to the main window that a new call is arriving
      // to open a popup
      PostMessage(Handle(Window_Call), "PhoneCall", nCallID, nStatus)
      // Information about the call is available
    CASE tapiCallInformation:
      // Signal to the main window that a new call is arriving
      // to open a popup
      PostMessage(Handle(Window_Call), "PhoneCallInfo", nCallID, nStatus)
      // The line was hung up
    CASE tapiLineDisconnected:
      // Signal to the main window that a new call is arriving
      // to open a popup
      PostMessage(Handle(Window_Call), "PhoneCallEnd", nCallID, nStatus)
    END
Related Examples:
WD Answering Machine Complete examples (WINDEV): WD Answering Machine
[ + ] This example uses the telephony features to manage an answering machine.
This program, powered by WINDEV, allows you to understand the use of the telephony functions for an answering machine.
This answering machine can be interrogated and configured (welcome message) remotely via a menu.
WD Telephony Complete examples (WINDEV): WD Telephony
[ + ] This example presents the telephony functions of WINDEV.
The following topics are presented in this example:
1/ How to dial a phone number
2/ Detect and identify the incoming calls
Summary of the example supplied with WINDEV:
This example presents the telephony functions supplied with WINDEV. Once contacts have been entered in the main window (the table is in edit), you will be able to call them from the application directly (your computer must be equipped with a modem properly installed). You will be able to get a notification for the incoming calls and to identify the caller
Pocket Telephony Mobile (WINDEV Mobile): Pocket Telephony
[ + ] This example is a telephony application that can be used on a Pocket PC equipped with a phone access (GSM).
This example uses the telephony functions of WINDEV Mobile as well as the functions used to retrieve the parameters of the phone.
It enables you to make phone calls, to receive phone calls and to manage a history of the calls (incoming and outgoing) as well as a database of contacts.
Furthermore, you have the ability to import the contacts found in the contact file of the Pocket PC.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment