home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
kvfon2.exe
/
LOGINDLG.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-02
|
9KB
|
270 lines
/****************************************************************************
** File: LOGINDLG.H
**
** Desc: Header file containing the login dialog source code.
**
** This file contains the login dialog source code for opening a stream, and
** getting ready for the rest of the csta calls.
**
** 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
*/
/****************************************************************************
** Declare a callback function for doing the acsEnumServers().
*/
Boolean FAR PASCAL _export ListTServers(char *serverName,unsigned long lParam);
/****************************************************************************
** This is the login dialog class.
*/
class TLoginDlg:public TDialog
{
public:
TLoginDlg(TWindow *parent, TResId resId,ACSHandle_t *acsHandle,
DeviceID_t *device);
void CmOk();
void SetupWindow();
void CleanupWindow();
ACSHandle_t *globalACSHandle;
DeviceID_t *usersExt;
TEdit *userNameField;
TEdit *passwordField;
TComboBox *tServersField;
TEdit *phoneExt;
DECLARE_RESPONSE_TABLE(TLoginDlg);
};
/****************************************************************************
** OWL uses this code to setup its windows message loop.
*/
DEFINE_RESPONSE_TABLE1(TLoginDlg,TDialog)
EV_COMMAND(IDOK,CmOk),
END_RESPONSE_TABLE;
/****************************************************************************
** login dialog constructor. We are just setting our member variables to
** the pointers that were passed to the constructor for the acsHandle and
** the device (the user's phone extension). This way, other objects in
** our program have access to these same values.
*/
TLoginDlg::TLoginDlg(TWindow *parent, TResId resId,ACSHandle_t *acsHandle,
DeviceID_t *device)
:TDialog(parent, resId),TWindow(parent)
{
globalACSHandle=acsHandle;
usersExt=device;
}
/****************************************************************************
** SetupWindow is called by OWL. We override it, first calling the parent's
** SetupWindow function.
*/
void TLoginDlg::SetupWindow()
{
EnumServerNamesCB serversList;
TDialog::SetupWindow();
/*------------------------------------------------------------------------
** We do the acsEnumServerNames here, to fill our combobox (drop down list
** box) with the names of the available telephony servers
*/
serversList=(EnumServerNamesCB) MakeProcInstance((FARPROC)ListTServers,NULL);
acsEnumServerNames(ST_CSTA,serversList,(unsigned long)this);
/*------------------------------------------------------------------------
** We created a dialog resource, which was already displayed. Now, in order
** to simplify getting the data out of the controls, we create new TEdit
** and TComboBox elements which point to the controls on the dialog that have
** already been created with the dialog.
*/
userNameField=new TEdit(this,IDC_USERNAME,100);
userNameField->Create();
passwordField=new TEdit(this,IDC_PASSWORD,100);
passwordField->Create();
tServersField=new TComboBox(this,IDC_COMBOBOX1,100);
tServersField->Create();
phoneExt=new TEdit(this,IDC_PHONEEXT,65);
phoneExt->Create();
}
/****************************************************************************
** CleanupWindow is called when the window is to be destroyed.
*/
void TLoginDlg::CleanupWindow()
{
/*------------------------------------------------------------------------
** delete the memory allocated in SetupWindow.
*/
delete userNameField;
delete passwordField;
delete tServersField;
delete phoneExt;
/*------------------------------------------------------------------------
** call the parent's CleanupWindow so we can be sure we get all the
** necessary functionality.
*/
TDialog::CleanupWindow();
}
/****************************************************************************
** CmOk is called when the user presses the OK button, to login.
*/
void TLoginDlg::CmOk()
{
/*------------------------------------------------------------------------
** necessary variables for the acsOpenStream() call, and a couple of
** miscellaneous data variables.
*/
ServerID_t serverID;
LoginID_t loginID;
Passwd_t password;
int textLen;
RetCode_t rCode;
InvokeID_t invokeID=0;
AppName_t appName;
Level_t acsLevelReq=ACS_LEVEL1;
Version_t apiVer;
unsigned short sendQSize=15;
unsigned short sendExtraBufs=0;
unsigned short recvQSize=15;
unsigned short recvExtraBufs=0;
PrivateData_t *privateData=NULL;
CSTAEvent_t eventBuffer;
unsigned short eventBufferSize;
unsigned short numEvents;
/*------------------------------------------------------------------------
** fill all of our variables with the data to open the acs stream
*/
strcpy(apiVer,CSTA_API_VERSION);
strcpy(appName,"KVPhone");
/*------------------------------------------------------------------------
** Did the user select a TServer?
*/
textLen=tServersField->GetStringLen(tServersField->GetSelIndex());
if(textLen>0)
{
/*---------------------------------------------------------------------
** get the data out of the edit boxes and the list box
*/
tServersField->GetText(serverID,textLen+1);
userNameField->GetLine(loginID,100,0);
passwordField->GetLine(password,100,0);
phoneExt->GetLine(*usersExt,65,0);
/*---------------------------------------------------------------------
** open the stream
*/
rCode=acsOpenStream(globalACSHandle,LIB_GEN_ID,invokeID,ST_CSTA,&serverID,
&loginID,&password,&appName,acsLevelReq,&apiVer,sendQSize,
sendExtraBufs,recvQSize,recvExtraBufs,privateData);
/*---------------------------------------------------------------------
** check to make sure it was opened correctly. If it was, we'll keep
** the acsHandle that was returned.
*/
if(rCode>0)
{
eventBufferSize=sizeof(CSTAEvent_t);
rCode=acsGetEventBlock(*globalACSHandle,&eventBuffer,&eventBufferSize,
privateData,&numEvents);
if(rCode==ACSPOSITIVE_ACK)
{
if(eventBuffer.eventHeader.eventType == ACS_OPEN_STREAM_CONF)
{
MessageBox("Stream Opened...","TS Success!");
}
else
{
MessageBox("Stream not opened","TS Error!");
/*------------------------------------------------------------
** stream not opened, set the acsHandle to 0
*/
*globalACSHandle=0;
}
}
else
{
MessageBox("Can't get event","TS Error!");
/*---------------------------------------------------------------
** stream not opened, set the acsHandle to 0
*/
*globalACSHandle=0;
}
}
else
{
MessageBox("Login Unsuccessful","TS Error!");
/*------------------------------------------------------------------
** stream not opened, set the acsHandle to 0
*/
*globalACSHandle=0;
}
}
/*------------------------------------------------------------------------
** call the parent's ok function for default processing.
*/
TDialog::CmOk();
}
/****************************************************************************
** this is the callback function. When we call acsEnumServerNames, from the
** login dialog, csta.dll will call this function for each telephony server
** that it can find, or until we return FALSE here. That is, if we return
** FALSE, we will not be notified of any more TServers. We return TRUE so
** we are notified of all TServers available.
*/
Boolean FAR PASCAL _export ListTServers(char *serverName,unsigned long lParam)
{
/*------------------------------------------------------------------------
** all we want to do is add the server name to the combobox on our dialog.
** we don't worry about saving the data in an array or anything. We are
** going to use the GetText() function to get the text of whatever item
** the user selected, so we don't have any reason to save these into an
** array.
*/
((TLoginDlg *)lParam)->SendDlgItemMessage(IDC_COMBOBOX1,CB_ADDSTRING,0,(LPARAM)serverName);
return TRUE;
}