home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
kvfon3.exe
/
PHONEDLG.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-22
|
19KB
|
635 lines
/****************************************************************************
** File: PHONEDLG.H
**
** Desc: Include files for the dialpad program.
**
** This file is an include file for the dialpad program. It contains the
** dialog source code for the dial pad, along with all of its functionality.
**
** It is written for OWL 2.0 with Borland C++ 4.x. To compile this program,
** create a project in BC4.x, similar to the .IDE project file included.
**
** DISCLAIMER
**
** Novell, Inc. makes no representations or warranties with respect to
** any NetWare software, and specifically disclaims any express or
** implied warranties of merchantability, title, or fitness for a
** particular purpose.
**
** You may use this sample code in your own programs.
**
** Distribution of any NetWare software is forbidden without the
** express written consent of Novell, Inc. Further, Novell reserves
** the right to discontinue distribution of any NetWare software.
**
** Novell is not responsible for lost profits or revenue, loss of use
** of the software, loss of data, costs of re-creating lost data, the
** cost of any substitute equipment or program, or claims by any party
** other than you. Novell strongly recommends a backup be made before
** any software is installed. Technical support for this software
** may be provided at the discretion of Novell.
**
** Programmers:
**
** Ini Who Firm
** -----------------------------------------------------------------------
** KVW Kevin V White Novell Developer Support.
**
** History:
**
** When Who What
** -----------------------------------------------------------------------
** 11-2 KVW First code release
** 11-16 KVW Added conference, transfer, hold, hangup connection
** 11-22 KVW Added Send Calls feature
*/
/****************************************************************************
** This is the dial pad dialog's class.
*/
class TPhoneDlg:public TDialog
{
public:
char numToDial[30];
short entryIndex;
DeviceID_t callerExt;
ACSHandle_t globalACSHandle;
CSTAEvent_t eventBuffer;
unsigned short eventBufferSize;
unsigned short numEvents;
DeviceID_t callee;
ConnectionID_t callID;
RetCode_t rCode;
InvokeID_t invokeID;
TEdit *numberEntryWindow;
BOOL SendCallStatus;
BOOL ForwardStatus;
TPhoneDlg(TWindow *parent,TResId resId,ACSHandle_t *acsHandle,
DeviceID_t *userExt);
void SetupWindow();
void CleanupWindow();
void CmDial1();
void CmDial2();
void CmDial3();
void CmDial4();
void CmDial5();
void CmDial6();
void CmDial7();
void CmDial8();
void CmDial9();
void CmDial0();
void CmDialNumber();
void CmHangupCall();
void CmHangupConn();
void CmHold();
void CmUnhold();
void CmHelp();
void CmClearEntry();
void CmConference();
void CmTransfer();
void CmSendCalls();
void CmForward();
DECLARE_RESPONSE_TABLE(TPhoneDlg);
};
/****************************************************************************
** this is how OWL adds message handling to the windows message loop
*/
DEFINE_RESPONSE_TABLE1(TPhoneDlg,TDialog)
EV_COMMAND(IDC_1,CmDial1),
EV_COMMAND(IDC_2,CmDial2),
EV_COMMAND(IDC_3,CmDial3),
EV_COMMAND(IDC_4,CmDial4),
EV_COMMAND(IDC_5,CmDial5),
EV_COMMAND(IDC_6,CmDial6),
EV_COMMAND(IDC_7,CmDial7),
EV_COMMAND(IDC_8,CmDial8),
EV_COMMAND(IDC_9,CmDial9),
EV_COMMAND(IDC_10,CmDial0),
EV_COMMAND(IDC_DIAL,CmDialNumber),
EV_COMMAND(IDC_HANGUPCALL,CmHangupCall),
EV_COMMAND(IDC_HANGUPCONN,CmHangupConn),
EV_COMMAND(IDC_HOLD,CmHold),
EV_COMMAND(IDC_UNHOLD,CmUnhold),
EV_COMMAND(IDC_HELP,CmHelp),
EV_COMMAND(IDC_CLEARENTRY,CmClearEntry),
EV_COMMAND(IDC_CONFERENCE,CmConference),
EV_COMMAND(IDC_TRANSFER,CmTransfer),
EV_COMMAND(IDC_SENDCALLS,CmSendCalls),
EV_COMMAND(IDC_FORWARD,CmForward),
END_RESPONSE_TABLE;
/****************************************************************************
** constructor for the dial pad dialog
*/
TPhoneDlg::TPhoneDlg(TWindow *parent,TResId resId,ACSHandle_t *acsHandle,
DeviceID_t *userExt)
:TDialog(parent,resId),TWindow(parent)
{
/*------------------------------------------------------------------------
** callerExt is the user's extension
** numToDial is a string built from the number the user dials
** entryIndex is the position in the array for the next digit dialed
** globalACSHandle is the acshandle we receive in the constructor
*/
strcpy(callerExt,*userExt);
numToDial[0]=0;
entryIndex=0;
strcpy(callerExt,*userExt);
globalACSHandle=*acsHandle;
eventBufferSize=sizeof(CSTAEvent_t);
SendCallStatus=FALSE;
ForwardStatus=FALSE;
}
/****************************************************************************
** SetupWindow is called when the dialog window is created
*/
void TPhoneDlg::SetupWindow()
{
/*------------------------------------------------------------------------
** first, call the parent's SetupWindow
*/
TDialog::SetupWindow();
/*------------------------------------------------------------------------
** create an alias to the text box in the dialog, as the alias will be
** easier to enter text into and retrieve text from than the dialog
*/
numberEntryWindow=new TEdit(this,IDC_NUMDISPLAY,30);
numberEntryWindow->Create();
}
/****************************************************************************
** CleanupWindow is called when the window is destroyed. We just use it to
** free the memory allocated to our TEdit alias in SetupWindow, then call
** the parent's CleanupWindow
*/
void TPhoneDlg::CleanupWindow()
{
delete numberEntryWindow;
TDialog::CleanupWindow();
}
/****************************************************************************
** these functinos are used when the user presses one of the buttons corres-
** ponding to the digits on the phone dial pad. In each one, we want to store
** the digit the user enters, increment the index into the character array,
** and then redisplay the string in the text window.
*/
void TPhoneDlg::CmDial1()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='1';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial2()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='2';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial3()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='3';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial4()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='4';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial5()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='5';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial6()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='6';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial7()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='7';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial8()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='8';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial9()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='9';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
void TPhoneDlg::CmDial0()
{
if(entryIndex<28)
{
numToDial[entryIndex++]='0';
numToDial[entryIndex]=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
}
/****************************************************************************
** Here we dial the number the user has entered.
*/
void TPhoneDlg::CmDialNumber()
{
BOOL done=FALSE;
/*------------------------------------------------------------------------
** has the user actually pressed the digits to make a number to dial?
*/
if(numToDial[0]!=0)
{
/*---------------------------------------------------------------------
** get the number dialed, and make the call.
*/
strcpy(callee,numToDial);
rCode=cstaMakeCall(globalACSHandle,invokeID,&callerExt,&callee,NULL);
/*---------------------------------------------------------------------
** if MakeCall was successful, it will return the invokeID (above 0)
*/
if(rCode>0)
{
/*------------------------------------------------------------------
** We enter a poll loop, waiting for our event to confirm the makecall
*/
while(!done)
{
/*---------------------------------------------------------------
** first, very important, set the event buffer size to pass to
** getEventPoll. If we don't reset it each time, it may be too
** small to get our event, and we will never get our make call
** confirmation event
*/
eventBufferSize=sizeof(CSTAEvent_t);
/*---------------------------------------------------------------
** get the event, and check its type
*/
rCode=acsGetEventPoll(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType==CSTA_MAKE_CALL_CONF)
{
/*---------------------------------------------------------
** if it's the right event type, the callID is stored in
** the confirmation event structure, which we will need to
** store so that the user can hangup on the call later. Then,
** we'll enable the appropriate buttons.
*/
callID=eventBuffer.event.cstaConfirmation.u.makeCall.newCall;
::EnableWindow(GetDlgItem(IDC_HANGUPCALL),1);
::EnableWindow(GetDlgItem(IDC_HANGUPCONN),1);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),1);
::EnableWindow(GetDlgItem(IDC_TRANSFER),1);
::EnableWindow(GetDlgItem(IDC_HOLD),1);
done=TRUE;
}
}
else if(rCode==ACSERR_NOMESSAGE)
{
done=FALSE;
}
else
{
/*------------------------------------------------------------
** we can't get the event that the call was made successfully,
** so disable the appropriate buttons.
*/
::EnableWindow(GetDlgItem(IDC_HANGUPCONN),0);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),0);
::EnableWindow(GetDlgItem(IDC_HANGUPCALL),0);
::EnableWindow(GetDlgItem(IDC_TRANSFER),0);
::EnableWindow(GetDlgItem(IDC_HOLD),0);
done=TRUE;
}
}
}
else
{
MessageBox("Unable to make call","TS Error!");
}
}
}
/****************************************************************************
** the user wants to hangup on a call. Note that this will only work on a
** call that the user created, as we have to have a valid callID. If that
** call was already cleared, well, we won't know about it, and will try to
** hang up on it anyway. That won't gpf or anything, but it would be a nice
** enhancement to monitor the device, and clear the hangup button if the call
** happens to be cleared by the user, and not through this program.
*/
void TPhoneDlg::CmHangupCall()
{
/*------------------------------------------------------------------------
** try to hangup on the call. we don't bother confirming that it worked,
** as we don't really care. We get an event, but don't check it's type.
** As we're only getting solicited events, this should be fine. One way
** or the other, we're going to disable appropriate buttons afterwards.
*/
rCode=cstaClearCall(globalACSHandle,invokeID,&callID,NULL);
if(rCode>0)
{
::EnableWindow(GetDlgItem(IDC_HANGUPCALL),0);
::EnableWindow(GetDlgItem(IDC_HANGUPCONN),0);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),0);
::EnableWindow(GetDlgItem(IDC_HOLD),0);
::EnableWindow(GetDlgItem(IDC_UNHOLD),0);
::EnableWindow(GetDlgItem(IDC_TRANSFER),0);
}
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
}
void TPhoneDlg::CmHangupConn()
{
/*------------------------------------------------------------------------
** try to hangup the connection. we don't bother confirming that it worked,
** as we don't really care. We get an event, but don't check it's type.
** As we're only getting solicited events, this should be fine. One way
** or the other, we're going to disable appropriate buttons afterwards.
*/
rCode=cstaClearConnection(globalACSHandle,invokeID,&callID,NULL);
if(rCode>0)
{
::EnableWindow(GetDlgItem(IDC_HANGUPCALL),0);
::EnableWindow(GetDlgItem(IDC_HANGUPCONN),0);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),0);
::EnableWindow(GetDlgItem(IDC_HOLD),0);
::EnableWindow(GetDlgItem(IDC_UNHOLD),0);
::EnableWindow(GetDlgItem(IDC_TRANSFER),0);
}
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
}
/*************************************************************************
** The user wants to put the call on hold
*/
void TPhoneDlg::CmHold()
{
/*---------------------------------------------------------------------
** put the call on hold
*/
rCode=cstaHoldCall(globalACSHandle,invokeID,&callID,FALSE,NULL);
if(rCode<=0)
{
return;
}
/*---------------------------------------------------------------------
** get an event
*/
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,NULL,
&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
/*------------------------------------------------------------------
** set or disable appropriate buttons
*/
::EnableWindow(GetDlgItem(IDC_UNHOLD),1);
::EnableWindow(GetDlgItem(IDC_HOLD),0);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),0);
::EnableWindow(GetDlgItem(IDC_TRANSFER),0);
}
return;
}
/*************************************************************************
** pick the call up from on hold
*/
void TPhoneDlg::CmUnhold()
{
/*---------------------------------------------------------------------
** pick up the call
*/
rCode=cstaRetrieveCall(globalACSHandle,invokeID,&callID,NULL);
if(rCode<=0)
{
return;
}
/*---------------------------------------------------------------------
** get an event
*/
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,NULL,
&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
/*------------------------------------------------------------------
** enable and disable appropriate buttons
*/
::EnableWindow(GetDlgItem(IDC_HOLD),1);
::EnableWindow(GetDlgItem(IDC_UNHOLD),0);
::EnableWindow(GetDlgItem(IDC_TRANSFER),1);
::EnableWindow(GetDlgItem(IDC_CONFERENCE),1);
}
return;
}
/****************************************************************************
** the user presed help. Display help as a simple dialog with text. If this
** were a more complex program, it would be nice to have a normal windows
** help file to use.
*/
void TPhoneDlg::CmHelp()
{
MessageBox(
"KVPhone is used as a dialpad for your phone with "
"NetWare Telephony Services.\n\n"
"Use the mouse to dial a number, then select Dial. \n\n"
"When on a phone conversation that you have created, you may press:\n"
"-Hangup Call to clear the call\n "
"-Hangup Conn to clear just your connectiona\n"
"-Conference to conference in another extension\n"
"-Transfer to transfer to another extionsion\n"
"-Hold to put the call on hold\n"
"-UnHold picks a call up from on hold\n"
"-Clear to clear the number display box to enter a new number.\n"
"-Send Calls will send incoming calls to your voice mail.\n"
"-Forward will forward your calls to another number."
,"KVPhone Help");
}
/****************************************************************************
** this is called to clear the number and start entering a new number to dial
*/
void TPhoneDlg::CmClearEntry()
{
numToDial[0]=0;
entryIndex=0;
SetDlgItemText(IDC_NUMDISPLAY,numToDial);
}
/*************************************************************************
** call the conference dialog to conference the call
*/
void TPhoneDlg::CmConference()
{
TConfDlg *confDlg=new TConfDlg(this,5,&globalACSHandle,&callerExt,&callID);
confDlg->Execute();
}
/*************************************************************************
** call the transfer dialog to transfer the call to another extionsion
*/
void TPhoneDlg::CmTransfer()
{
TXferDlg *xferDlg=new TXferDlg(this,1,&globalACSHandle,&callerExt,&callID);
xferDlg->Execute();
}
/*************************************************************************
** send the calls to the cover extension. In order to do this, the
** extension cannot be a DCS extension. In other words, it must be an
** actual extension on this pbx.
*/
void TPhoneDlg::CmSendCalls()
{
if(SendCallStatus)
{
SendCallStatus=FALSE;
rCode=cstaSetDoNotDisturb(globalACSHandle,invokeID,&callerExt,FALSE,NULL);
if(rCode>0)
{
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
return;
}
else
{
MessageBox("Event returned wrong","Send Calls");
return;
}
}
else
{
MessageBox("Cannot Turn Off Send Calls","Send Calls Error");
return;
}
}
else
{
SendCallStatus=TRUE;
rCode=cstaSetDoNotDisturb(globalACSHandle,invokeID,&callerExt,TRUE,NULL);
if(rCode>0)
{
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
return;
}
else
{
MessageBox("Event returned wrong","Send Calls");
return;
}
}
else
{
MessageBox("Cannot Turn On Send Calls","Send Calls Error");
return;
}
}
}
/*************************************************************************
** call the forward dialog to forward the calls to another extionsion
*/
void TPhoneDlg::CmForward()
{
if(ForwardStatus==FALSE)
{
TForward *forwardDlg=new TForward(this,8,&globalACSHandle,&callerExt,
&ForwardStatus);
forwardDlg->Execute();
}
else
{
ForwardStatus=FALSE;
rCode=cstaSetForwarding(globalACSHandle,invokeID,&callerExt,
FWD_IMMEDIATE,FALSE,&callerExt,NULL);
if(rCode>0)
{
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(globalACSHandle,&eventBuffer,&eventBufferSize,
NULL,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
}
else
{
MessageBox("Event returned wrong","Forward Calls");
}
}
else
{
MessageBox("Cannot Turn Off Forward Calls","Forward Calls Error");
}
}
}