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

  1. /****************************************************************************
  2. **    File:    KVPHONE2.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. */
  49.  
  50.  
  51. /****************************************************************************
  52. **    Include headers, macros, function prototypes, etc.
  53. */
  54.  
  55.     /*------------------------------------------------------------------------
  56.     **    Borland C++ 4.x OWL libraries
  57.     */
  58.     #include <owl\applicat.h>
  59.     #include <owl\framewin.h>
  60.     #include <owl\dialog.h>
  61.     #include <owl\edit.h>
  62.     #include <owl\combobox.h>
  63.  
  64.     /*------------------------------------------------------------------------
  65.     **    NetWare Telephony Services TSAPI libraries
  66.     */
  67.     #include <acs.h>
  68.     #include <csta.h>
  69.  
  70.     /*------------------------------------------------------------------------
  71.     **    Project include files for the dialogs, #define's, and other functions.
  72.     */
  73.     #include "phonerc.h"
  74.     #include "confdlg.h"
  75.     #include "xferdlg.h"
  76.     #include "phonedlg.h"
  77.     #include "logindlg.h"
  78.  
  79.  
  80. /****************************************************************************
  81. **    This is the main window class.
  82. */
  83. class TPhoneWindow:public TFrameWindow
  84. {
  85.     public:
  86.         TPhoneWindow(TWindow *parent, const char far *title,TWindow *clientWnd,
  87.             BOOL shrinkToClient,ACSHandle_t *globalACSHandle,
  88.             DeviceID_t *deviceID);
  89.  
  90.         char numberToDial[20];
  91.         ACSHandle_t    *acsHandle;
  92.         DeviceID_t    *phoneExt;
  93.         TWindow *mainWindowDialog;
  94.  
  95.     DECLARE_RESPONSE_TABLE(TPhoneWindow);
  96. };
  97.  
  98. DEFINE_RESPONSE_TABLE1(TPhoneWindow,TFrameWindow)
  99. END_RESPONSE_TABLE;
  100.  
  101. /****************************************************************************
  102. **    Main window constructor
  103. */
  104. TPhoneWindow::TPhoneWindow(TWindow *parent, const char far *title,
  105.     TWindow *clientWnd,BOOL shrinkToClient,ACSHandle_t *globalACSHandle,
  106.     DeviceID_t *deviceID)
  107.     :TFrameWindow(parent,title,clientWnd,shrinkToClient),TWindow(parent,title)
  108. {
  109.     acsHandle=globalACSHandle;
  110.     phoneExt=deviceID;
  111.     mainWindowDialog=clientWnd;
  112.     numberToDial[0]=0;
  113.     AssignMenu(1);
  114. }
  115.  
  116. /****************************************************************************
  117. **    Application class.
  118. */
  119. class TPhoneApp:public TApplication
  120. {
  121.     public:
  122.         ACSHandle_t *globalACSHandle;
  123.         DeviceID_t *deviceID;
  124.         TPhoneApp(char *title,ACSHandle_t *acsHandle,DeviceID_t *extension);
  125.         void InitMainWindow();
  126. };
  127.  
  128. /****************************************************************************
  129. **    Application constructor.
  130. */
  131. TPhoneApp::TPhoneApp(char *title,ACSHandle_t *acsHandle,DeviceID_t *extension)
  132.     :TApplication(title)
  133. {
  134.     globalACSHandle=acsHandle;
  135.     deviceID=extension;
  136. }
  137.  
  138. /****************************************************************************
  139. **    declare a new main window, using a dialog as the main window
  140. */
  141. void TPhoneApp::InitMainWindow()
  142. {
  143.     MainWindow=new TPhoneWindow(0,"KVPhone",
  144.         new TPhoneDlg(0,2,globalACSHandle,deviceID),
  145.         TRUE,globalACSHandle,deviceID);
  146. }
  147.  
  148. /****************************************************************************
  149. **    this is the main function
  150. */
  151. int OwlMain(int /*argc*/,char */*argv*/[])
  152. {
  153.     ACSHandle_t acsHandle;
  154.     DeviceID_t extension;
  155.     int rCode;
  156.  
  157.     /*------------------------------------------------------------------------
  158.     **    If they login successfully to the TServer, then continue on with
  159.     **    the program, aborting the stream when exiting.  Otherwise, just
  160.     **    return an error code.
  161.     */
  162.     TLoginDlg *loginDlg=new TLoginDlg(0,TResId(3),&acsHandle,&extension);
  163.     if(loginDlg->Execute()==IDOK)
  164.     {
  165.         if(acsHandle!=0)
  166.         {
  167.             TPhoneApp app("KVPhone",&acsHandle,&extension);
  168.             rCode=app.Run();
  169.             acsAbortStream(acsHandle,NULL);
  170.             return rCode;
  171.         }
  172.         else
  173.         {
  174.             return 0xFF;
  175.         }
  176.     }
  177. }
  178.