home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / kvfon1.exe / PHONE.CPP < prev    next >
C/C++ Source or Header  |  1994-11-02  |  5KB  |  173 lines

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