home *** CD-ROM | disk | FTP | other *** search
/ Network Support Encyclopedia 96-1 / novell-nsepro-1996-1-cd2.iso / download / netware / kvfon2.exe / XFERDLG.H < prev   
C/C++ Source or Header  |  1994-11-16  |  7KB  |  221 lines

  1. /****************************************************************************
  2. **    File:    XFERDLG.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 transferring 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 transfer dialog's class.
  47. */
  48. class TXferDlg:public TDialog
  49. {
  50.     public:
  51.         ACSHandle_t    globalACSHandle;
  52.         DeviceID_t  xferExt,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.         TXferDlg(TWindow *parent,TResId resId,ACSHandle_t *acsHandle,
  62.             DeviceID_t *caller,ConnectionID_t *oldCallID);
  63.         void SetupWindow();
  64.         void CleanupWindow();
  65.         void CmTransfer();
  66.  
  67.     DECLARE_RESPONSE_TABLE(TXferDlg);
  68. };
  69.  
  70. /****************************************************************************
  71. **    this is how OWL adds message handling to the windows message loop
  72. */
  73. DEFINE_RESPONSE_TABLE1(TXferDlg,TDialog)
  74.     EV_COMMAND(IDOK,CmTransfer),
  75. END_RESPONSE_TABLE;
  76.  
  77. /****************************************************************************
  78. **    constructor for the transfer call dialog
  79. */
  80. TXferDlg::TXferDlg(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 TXferDlg::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 TXferDlg::CleanupWindow()
  113. {
  114.     delete extEntryBox;
  115.  
  116.     TDialog::CleanupWindow();
  117. }
  118.  
  119. /****************************************************************************
  120. **    Here we actually transfer the call
  121. */
  122. void TXferDlg::CmTransfer()
  123. {
  124.     /*-----------------------------------------------------------------------
  125.     **    get the extension to transfer to
  126.     */
  127.     extEntryBox->GetLine(xferExt,30,0);
  128.     if(strlen(xferExt)<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 transfer 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.         **    make the second call
  159.         */
  160.         rCode=cstaMakeCall(globalACSHandle,invokeID,&callerExt,&xferExt,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.                     **    get the new call id
  178.                     */
  179.                     newCallID=eventBuffer.event.cstaConfirmation.u.makeCall.newCall;
  180.                 }
  181.             }
  182.         }
  183.         else
  184.         {
  185.             MessageBox("Unable to make call","TS Error!");
  186.         }
  187.         /*---------------------------------------------------------------------
  188.         **    with the first call (callID) on hold, and the second call active
  189.         **    (newCallID), we can transfer the call.
  190.         */
  191.         rCode=cstaTransferCall(globalACSHandle,invokeID,callID,&newCallID,NULL);
  192.         if(rCode<=0)
  193.         {
  194.             MessageBox("Can't transfer","Transfer Error");
  195.             return;
  196.         }
  197.         else
  198.         {
  199.             eventBufferSize=sizeof(CSTAEvent_t);
  200.             rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
  201.                 NULL,&numEvents);
  202.             if(rCode==ACSPOSITIVE_ACK)
  203.             {
  204.                 /*------------------------------------------------------------
  205.                 **    set the appropriate button states, as we no longer have the
  206.                 **    active call at this extension
  207.                 */
  208.                 ::EnableWindow(Parent->GetDlgItem(IDC_HANGUPCONN),0);
  209.                 ::EnableWindow(Parent->GetDlgItem(IDC_HANGUPCALL),0);
  210.                 ::EnableWindow(Parent->GetDlgItem(IDC_CONFERENCE),0);
  211.                 ::EnableWindow(Parent->GetDlgItem(IDC_HOLD),0);
  212.                 ::EnableWindow(Parent->GetDlgItem(IDC_UNHOLD),0);
  213.                 ::EnableWindow(Parent->GetDlgItem(IDC_TRANSFER),0);
  214.             }
  215.         }
  216.     }
  217.     TDialog::CmOk();
  218.     return;
  219. }
  220.  
  221.