home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / kvfon3.exe / KVPHONE3.CPP < prev    next >
C/C++ Source or Header  |  1994-11-22  |  6KB  |  181 lines

  1. /****************************************************************************
  2. **    File:    KVPHONE3.CPP
  3. **
  4. **    Desc:    Sample telephony program
  5. **
  6. **    This NetWare Telephony Services program is a phone dialpad.  It uses the
  7. **    TSAPI for opening a stream, making calls, clearing calls and connections,
  8. **    conferencing and transfering calls, putting calls on hold, and demonstrates
  9. **    event polling loops.  Also demonstrates using the CSTA.LIB functions from
  10. **    a C++ program.
  11. **
  12. **    It is written for OWL 2.0 with Borland C++ 4.x.  To compile this program,
  13. **    create a project in BC4.x, similar to the .IDE project file included.
  14. **
  15. **        DISCLAIMER
  16. **
  17. **    Novell, Inc. makes no representations or warranties with respect to
  18. **    any NetWare software, and specifically disclaims any express or
  19. **    implied warranties of merchantability, title, or fitness for a
  20. **    particular purpose.
  21. **
  22. **    You may use this sample code in your own programs.
  23. **
  24. **    Distribution of any NetWare software is forbidden without the
  25. **    express written consent of Novell, Inc.  Further, Novell reserves
  26. **    the right to discontinue distribution of any NetWare software.
  27. **
  28. **    Novell is not responsible for lost profits or revenue, loss of use
  29. **    of the software, loss of data, costs of re-creating lost data, the
  30. **    cost of any substitute equipment or program, or claims by any party
  31. **    other than you.  Novell strongly recommends a backup be made before
  32. **    any software is installed.   Technical support for this software
  33. **    may be provided at the discretion of Novell.
  34. **
  35. **    Programmers:
  36. **
  37. **        Ini    Who                        Firm
  38. **        -----------------------------------------------------------------------
  39. **        KVW    Kevin V White        Novell Developer Support.
  40. **
  41. **    History:
  42. **
  43. **        When        Who    What
  44. **        -----------------------------------------------------------------------
  45. **        11-2        KVW    First code release
  46. **        11-16        KVW    Added functionality for conference, transfer, hold
  47. **        11-16        KVW     Split "hangup" into clear connection and clear call
  48. **        11-22        KVW    Added SendCalls and Forward
  49. */
  50.  
  51.  
  52. /****************************************************************************
  53. **    Include headers, macros, function prototypes, etc.
  54. */
  55.  
  56.     /*------------------------------------------------------------------------
  57.     **    Borland C++ 4.x OWL libraries
  58.     */
  59.     #include <owl\applicat.h>
  60.     #include <owl\framewin.h>
  61.     #include <owl\dialog.h>
  62.     #include <owl\edit.h>
  63.     #include <owl\combobox.h>
  64.     #include <stdio.h>
  65.  
  66.     /*------------------------------------------------------------------------
  67.     **    NetWare Telephony Services TSAPI libraries
  68.     */
  69.     #include <acs.h>
  70.     #include <csta.h>
  71.  
  72.     /*------------------------------------------------------------------------
  73.     **    Project include files for the dialogs, #define's, and other functions.
  74.     */
  75.     #include "phonerc.h"
  76.     #include "confdlg.h"
  77.     #include "xferdlg.h"
  78.     #include "forward.h"
  79.     #include "phonedlg.h"
  80.     #include "logindlg.h"
  81.  
  82.  
  83. /****************************************************************************
  84. **    This is the main window class.
  85. */
  86. class TPhoneWindow:public TFrameWindow
  87. {
  88.     public:
  89.         TPhoneWindow(TWindow *parent, const char far *title,TWindow *clientWnd,
  90.             BOOL shrinkToClient,ACSHandle_t *globalACSHandle,
  91.             DeviceID_t *deviceID);
  92.  
  93.         char numberToDial[20];
  94.         ACSHandle_t    *acsHandle;
  95.         DeviceID_t    *phoneExt;
  96.         TWindow *mainWindowDialog;
  97.  
  98.     DECLARE_RESPONSE_TABLE(TPhoneWindow);
  99. };
  100.  
  101. DEFINE_RESPONSE_TABLE1(TPhoneWindow,TFrameWindow)
  102. END_RESPONSE_TABLE;
  103.  
  104. /****************************************************************************
  105. **    Main window constructor
  106. */
  107. TPhoneWindow::TPhoneWindow(TWindow *parent, const char far *title,
  108.     TWindow *clientWnd,BOOL shrinkToClient,ACSHandle_t *globalACSHandle,
  109.     DeviceID_t *deviceID)
  110.     :TFrameWindow(parent,title,clientWnd,shrinkToClient),TWindow(parent,title)
  111. {
  112.     acsHandle=globalACSHandle;
  113.     phoneExt=deviceID;
  114.     mainWindowDialog=clientWnd;
  115.     numberToDial[0]=0;
  116.     AssignMenu(1);
  117. }
  118.  
  119. /****************************************************************************
  120. **    Application class.
  121. */
  122. class TPhoneApp:public TApplication
  123. {
  124.     public:
  125.         ACSHandle_t *globalACSHandle;
  126.         DeviceID_t *deviceID;
  127.         TPhoneApp(char *title,ACSHandle_t *acsHandle,DeviceID_t *extension);
  128.         void InitMainWindow();
  129. };
  130.  
  131. /****************************************************************************
  132. **    Application constructor.
  133. */
  134. TPhoneApp::TPhoneApp(char *title,ACSHandle_t *acsHandle,DeviceID_t *extension)
  135.     :TApplication(title)
  136. {
  137.     globalACSHandle=acsHandle;
  138.     deviceID=extension;
  139. }
  140.  
  141. /****************************************************************************
  142. **    declare a new main window, using a dialog as the main window
  143. */
  144. void TPhoneApp::InitMainWindow()
  145. {
  146.     MainWindow=new TPhoneWindow(0,"KVPhone",
  147.         new TPhoneDlg(0,2,globalACSHandle,deviceID),
  148.         TRUE,globalACSHandle,deviceID);
  149. }
  150.  
  151. /****************************************************************************
  152. **    this is the main function
  153. */
  154. int OwlMain(int /*argc*/,char */*argv*/[])
  155. {
  156.     ACSHandle_t acsHandle;
  157.     DeviceID_t extension;
  158.     int rCode;
  159.  
  160.     /*------------------------------------------------------------------------
  161.     **    If they login successfully to the TServer, then continue on with
  162.     **    the program, aborting the stream when exiting.  Otherwise, just
  163.     **    return an error code.
  164.     */
  165.     TLoginDlg *loginDlg=new TLoginDlg(0,TResId(3),&acsHandle,&extension);
  166.     if(loginDlg->Execute()==IDOK)
  167.     {
  168.         if(acsHandle!=0)
  169.         {
  170.             TPhoneApp app("KVPhone",&acsHandle,&extension);
  171.             rCode=app.Run();
  172.             acsAbortStream(acsHandle,NULL);
  173.             return rCode;
  174.         }
  175.         else
  176.         {
  177.             return 0xFF;
  178.         }
  179.     }
  180. }
  181.