ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / Phone functions
  • Principle
  • Steps to follow
  • Example
  • Example used to manage the incoming calls in the main thread
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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.
Steps to follow
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:
    tapiCapabilityReturns the characteristics of a telephony device.
    tapiDeviceSelects the TAPI device that will be used during the following telephony operations:
    tapiDeviceListLists the TAPI 2.0 and TAPI 3.1 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:
      • telLigneOccupée: Line is currently busy.
      • telLigneDécrochée: The line is connected.
      • telLineNumber: Dialing in progress.
      • telLigneTonalité: Line receives dial tone
      • telLigneRaccrochée: The correspondent has hung up
      • telLineAttendAnswer: The call is dialed: search for the correspondent
      • telLigneSonnerie: Ringing tone in progress at the correspondent's address
      • telNewCall New call detected waiting to be answered or rejected.
      • telInformationAppel: Additional information (number presentation) is available at. 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:
        tapiCallDuringReturns the duration of the call (difference between the start date and time of call and the end date and time of call).
        tapiCallEndReturns the date and time of the end of call.
        tapiCallerIDUsed to find out the calling phone number (the one that calls).
        tapiCallIsOverUsed to find out whether the incoming or outgoing call is ended.
        tapiCallStartReturns the date and time of the beginning of call (incoming or outgoing call).
      • perform specific operations:
        tapiAnswerCallAnswers an incoming call that was detected.
        tapiKeyPressedReturns the history of the keys pressed on the phone keypad since the last call to tapiKeyPressed.
        tapiPlayPlays a sound file (.WAV) for the specified line.
        tapiRecordRecords the current communication as a".WAV" file.
        tapiSendKeyAllows you to simulate the use of phone keys.
        tapiStopStops reading a pre-recorded message (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, ...). For more details, see Managing threads with WINDEV.
        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 
    gnIDEvenement is int 
    // On met en place un événement pour gérer les appels entrant en popup 
    IF Event("AppelDetecté", "*.*", "AppelTel") = 0 THEN 
    	Error("Impossible de gérer la popup de détection d'appel", ErrorInfo()) 
    END 
    IF Event("FinAppelDetecté", "*.*", "AppelTelFin") = 0 THEN 
    	Error("Impossible de gérer la popup de détection d'appel", ErrorInfo()) 
    END 
    IF Event("IdentifiantAppelDetecté", "*.*", "AppelTelInfo") = 0 THEN 
    	Error("Impossible de gérer la popup de détection d'appel", ErrorInfo()) 
    END
  • Window initialization code: this code starts the call detection procedure.
    // On démarre le service de détection des appels 
    IF tapiListen("AppelEntrant", tapiOptionMediaModeFax, "DetectionAppel") THEN 
    	// Le service de détection des appels a démarré 
    	Message("Détection des appels activés") 
    ELSE 
    	// Le service de détection des appels n'a pas démarré 
    	 Error("Impossible de démarrer la détection des appels" + CR + ...
    			"Détail de l'erreur :" + 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.
    PROCEDURE DetectionAppel(nIDService, nIDAppel, nStatut) 
    // AVERTISSEMENT : 
    // Les traitements réalisés dans cette procédure sont appelés à partir d'un thread 
    // La gestion de l'affichage doit être réalisé à partir du thread principal
    // (d'où l'utilisation de PostMessage) 
    // Pour déboguer ce type de traitement, vous devez utiliser la fonction "Trace" 
    // détection des appels entrants 
    SWITCH nStatut 
    	// Détection d'un nouvel appel : 
    	// Note : On ne disposera de plus d'informations qu'après au moins une sonnerie 
    	CASE tapiNewCall : 
    	  // On signale l'arrivée d'un nouvel appel à la fenêtre principale 
    	  // pour ouvrir une Popup 
    	  PostMessage(Handle(Fenêtre_Appel), "AppelTel", nIDAppel, nStatut) 
    	  // On dispose d'informations sur l'appel 
    	CASE tapiCallInformation : 
    	  // On signale l'arrivée d'un nouvel appel à la fenêtre principale 
    	  // pour ouvrir une Popup 
    	  PostMessage(Handle(Fenêtre_Appel), "AppelTelInfo", nIDAppel, nStatut) 
    	  // La ligne a été raccrochée 
    	CASE tapiLineDisconnected: 
    	  // On signale l'arrivée d'un nouvel appel à la fenêtre principale 
    	  // pour ouvrir une Popup 
    	  PostMessage(Handle(Fenêtre_Appel), "AppelTelFin", nIDAppel, nStatut) 
    END
Related Examples:
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
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help