home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / kvfon2.exe / CONFDLG.H next >
C/C++ Source or Header  |  1994-11-16  |  8KB  |  228 lines

  1. /****************************************************************************
  2. **    File:    CONFDLG.H
  3. **
  4. **    Desc:    Include files for the dialpad program.
  5. **
  6. **    This file is an include file for the dialpad program.  It contains the
  7. **    dialog source for conferencing a call.
  8. **
  9. **    It is written for OWL 2.0 with Borland C++ 4.x.  To compile this program,
  10. **    create a project in BC4.x, similar to the .IDE project file included.
  11. **
  12. **        DISCLAIMER
  13. **
  14. **    Novell, Inc. makes no representations or warranties with respect to
  15. **    any NetWare software, and specifically disclaims any express or
  16. **    implied warranties of merchantability, title, or fitness for a
  17. **    particular purpose.
  18. **
  19. **    You may use this sample code in your own programs.
  20. **
  21. **    Distribution of any NetWare software is forbidden without the
  22. **    express written consent of Novell, Inc.  Further, Novell reserves
  23. **    the right to discontinue distribution of any NetWare software.
  24. **
  25. **    Novell is not responsible for lost profits or revenue, loss of use
  26. **    of the software, loss of data, costs of re-creating lost data, the
  27. **    cost of any substitute equipment or program, or claims by any party
  28. **    other than you.  Novell strongly recommends a backup be made before
  29. **    any software is installed.   Technical support for this software
  30. **    may be provided at the discretion of Novell.
  31. **
  32. **    Programmers:
  33. **
  34. **        Ini    Who                        Firm
  35. **        -----------------------------------------------------------------------
  36. **        KVW    Kevin V White        Novell Developer Support.
  37. **
  38. **    History:
  39. **
  40. **        When        Who    What
  41. **        -----------------------------------------------------------------------
  42. **        11-16        KVW    This feature is new
  43. */
  44.  
  45. /****************************************************************************
  46. **    This is the conference dialog's class.
  47. */
  48. class TConfDlg:public TDialog
  49. {
  50.     public:
  51.         ACSHandle_t    globalACSHandle;
  52.         DeviceID_t  confExt,callerExt;
  53.         ConnectionID_t    *callID,newCallID;
  54.         CSTAEvent_t eventBuffer;
  55.         unsigned short eventBufferSize;
  56.         unsigned short numEvents;
  57.         RetCode_t rCode;
  58.         InvokeID_t invokeID;
  59.         TEdit *extEntryBox;
  60.  
  61.         TConfDlg(TWindow *parent,TResId resId,ACSHandle_t *acsHandle,
  62.             DeviceID_t *caller,ConnectionID_t *oldCallID);
  63.         void SetupWindow();
  64.         void CleanupWindow();
  65.         void CmConference();
  66.  
  67.     DECLARE_RESPONSE_TABLE(TConfDlg);
  68. };
  69.  
  70. /****************************************************************************
  71. **    this is how OWL adds message handling to the windows message loop
  72. */
  73. DEFINE_RESPONSE_TABLE1(TConfDlg,TDialog)
  74.     EV_COMMAND(IDOK,CmConference),
  75. END_RESPONSE_TABLE;
  76.  
  77. /****************************************************************************
  78. **    constructor for the conference call dialog
  79. */
  80. TConfDlg::TConfDlg(TWindow *parent,TResId resId,ACSHandle_t *acsHandle,
  81.     DeviceID_t *caller,ConnectionID_t *oldCallID)
  82.     :TDialog(parent,resId),TWindow(parent)
  83. {
  84.     globalACSHandle=*acsHandle;
  85.     strcpy(callerExt,*caller);
  86.     callID=oldCallID;
  87. }
  88.  
  89. /****************************************************************************
  90. ** SetupWindow is called when the dialog window is created
  91. */
  92. void TConfDlg::SetupWindow()
  93. {
  94.     /*------------------------------------------------------------------------
  95.     ** first, call the parent's SetupWindow
  96.     */
  97.     TDialog::SetupWindow();
  98.  
  99.     /*------------------------------------------------------------------------
  100.     ** create an alias to the text box in the dialog, as the alias will be
  101.     ** easier to enter text into and retrieve text from than the dialog
  102.     */
  103.     extEntryBox=new TEdit(this,IDC_EDIT1,30);
  104.     extEntryBox->Create();
  105. }
  106.  
  107. /****************************************************************************
  108. **    CleanupWindow is called when the window is destroyed.  We just use it to
  109. ** free the memory allocated to our TEdit alias in SetupWindow, then call
  110. **    the parent's CleanupWindow
  111. */
  112. void TConfDlg::CleanupWindow()
  113. {
  114.     delete extEntryBox;
  115.  
  116.     TDialog::CleanupWindow();
  117. }
  118.  
  119. /****************************************************************************
  120. **    Here we actually do the conference call.
  121. */
  122. void TConfDlg::CmConference()
  123. {
  124.     /*---------------------------------------------------------------------
  125.     **    get the extension the user entered
  126.     */
  127.     extEntryBox->GetLine(confExt,30,0);
  128.     if(strlen(confExt)<1)
  129.     {
  130.         return;
  131.     }
  132.     else
  133.     {
  134.         /*------------------------------------------------------------------
  135.         **    put the first call on hold
  136.         */
  137.         rCode=cstaHoldCall(globalACSHandle,invokeID,callID,FALSE,NULL);
  138.         if(rCode<=0)
  139.         {
  140.             MessageBox("Can't Conference a Call.  Can't put the call on hold",
  141.                 "Hold Call");
  142.             return;
  143.         }
  144.         eventBufferSize=sizeof(CSTAEvent_t);
  145.         rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,NULL,
  146.             &numEvents);
  147.         if(rCode==ACSPOSITIVE_ACK)
  148.         {
  149.             ::EnableWindow(Parent->GetDlgItem(IDC_UNHOLD),1);
  150.             ::EnableWindow(Parent->GetDlgItem(IDC_HOLD),0);
  151.         }
  152.         else
  153.         {
  154.             MessageBox("rCode wrong from getEventBlock","Can't hold call");
  155.             return;
  156.         }
  157.         /*------------------------------------------------------------------
  158.         **    call the next extension
  159.         */
  160.         rCode=cstaMakeCall(globalACSHandle,invokeID,&callerExt,&confExt,NULL);
  161.         /*---------------------------------------------------------------------
  162.         **    if MakeCall was successful, it will return the invokeID (above 0)
  163.         */
  164.         if(rCode>0)
  165.         {
  166.             eventBufferSize=sizeof(CSTAEvent_t);
  167.             /*---------------------------------------------------------------
  168.             **    get the event, and check its type
  169.             */
  170.             rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
  171.                 NULL,&numEvents);
  172.             if(rCode==ACSPOSITIVE_ACK)
  173.             {
  174.                 if(eventBuffer.eventHeader.eventType==CSTA_MAKE_CALL_CONF)
  175.                 {
  176.                     /*---------------------------------------------------------
  177.                     **    if it's the right event type, the callID is stored in
  178.                     ** the confirmation event structure, which we will need to
  179.                     ** store so that the user can hangup on the call later.
  180.                     */
  181.                     newCallID=eventBuffer.event.cstaConfirmation.u.makeCall.newCall;
  182.                 }
  183.             }
  184.         }
  185.         else
  186.         {
  187.             MessageBox("Unable to make call","TS Error!");
  188.         }
  189.         /*------------------------------------------------------------------
  190.         **    with the first call on hold (callID) and the second call active
  191.         **    (newCallID), conference the two calls to make one single call,
  192.         **    for which we will retrieve a new call id
  193.         */
  194.         rCode=cstaConferenceCall(globalACSHandle,invokeID,callID,&newCallID,NULL);
  195.         if(rCode<=0)
  196.         {
  197.             MessageBox("Can't conference","Conference Error");
  198.             return;
  199.         }
  200.         else
  201.         {
  202.             eventBufferSize=sizeof(CSTAEvent_t);
  203.             rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
  204.                 NULL,&numEvents);
  205.             if(rCode==ACSPOSITIVE_ACK)
  206.             {
  207.                 /*---------------------------------------------------------------
  208.                 **    this is the new call id from the conference call confirmation
  209.                 **    event
  210.                 */
  211.                 newCallID=eventBuffer.event.cstaConfirmation.u.makeCall.newCall;
  212.                 *callID=newCallID;
  213.                 /*--------------------------------------------------------------
  214.                 **    set the appropriate button states for an active call
  215.                 */
  216.                 ::EnableWindow(Parent->GetDlgItem(IDC_HANGUPCONN),1);
  217.                 ::EnableWindow(Parent->GetDlgItem(IDC_HANGUPCALL),1);
  218.                 ::EnableWindow(Parent->GetDlgItem(IDC_CONFERENCE),0);
  219.                 ::EnableWindow(Parent->GetDlgItem(IDC_HOLD),1);
  220.                 ::EnableWindow(Parent->GetDlgItem(IDC_UNHOLD),0);
  221.             }
  222.         }
  223.     }
  224.     TDialog::CmOk();
  225.     return;
  226. }
  227.  
  228.