1 line
8.7 KiB
C
1 line
8.7 KiB
C
|
// ===========================================================================
// UAMDialogs.c <09> 1997 Microsoft Corp. All rights reserved.
// ===========================================================================
// General dialog utilities used by the Microsoft User Authentication Method.
//
// ===========================================================================
#include <Sound.h>
#include "UAMDebug.h"
#include "UAMDialogs.h"
#include "UAMUtils.h"
#include "UAMMain.h"
#include "UAMNetwork.h"
#include "UAMDSNetwork.h"
#include "UAMListBox.h"
#include "UAMDLOGUtils.h"
#include "UAMKeychain.h"
extern Str32 gServerName;
extern ModalFilterUPP gDialogFilter;
extern UserItemUPP gLineItem;
extern long gSupportedUAMs;
// ---------------------------------------------------------------------------
// <09> UAM_ReportError()
// ---------------------------------------------------------------------------
// Reports an error to the user by displaying an alert box. This routine looks
// in the resource file for a resource of type 'ESTR' with the same res ID as
// the error code. If found, the message contained in the resource is displayed
// to the user.
//
// Note that we go out our way here by putting up and maintaining our own error
// alert box instead of using one of the Alert routines. This is because other
// dialogs in the UAM use ParamText() to set string information. If we have
// an error, then the strings will be replaced by the alert strings. Not a
// good scenario...
#define DITEM_MsgText 3
void UAM_ReportError(OSStatus inError)
{
Str255 theMsg;
short theItem;
StringHandle theString;
DialogPtr theDialog = NULL;
GrafPtr theSavePort = NULL;
Assert_(gDialogFilter != NULL);
if (inError != noErr)
{
GetPort(&theSavePort);
InitCursor();
UAM_PStrCopy("\p", theMsg);
theString = (StringHandle)Get1Resource('STR ', inError);
if (theString)
{
HLock((Handle)theString);
UAM_PStrCopy(*theString, theMsg);
HUnlock((Handle)theString);
ReleaseResource((Handle)theString);
}
theDialog = UAM_NewDialog(DLOG_GeneralError, true);
Assert_(theDialog != NULL);
if (theDialog != NULL)
{
SysBeep(1);
UAM_SetText(theDialog, DITEM_MsgText, theMsg);
do
{
ModalDialog(gDialogFilter, &theItem);
}while(theItem != 1);
UAM_DisposeDialog(theDialog);
SetPort(theSavePort);
}
}
}
// ---------------------------------------------------------------------------
// <09> UAM_ChangePwd()
// ---------------------------------------------------------------------------
// Puts up and handles the change password dialog and calls the appropriate
// routines to change the password.
//
// Unless there is an error, we'll usually return one of:
//
// #define CHNGPSWD_UPDATE_KEYCHAIN 1000
// #define CHNGPSWD_USER_CANCELED 1001
// #define CHNGPSWD_NOERR noErr
#define DITEM_Icon 3
#define DITEM_OldPassword 6
#define DITEM_NewPassword 8
#define DITEM_VerifyPwd 10
#define DITEM_LineItem 11
OSStatus UAM_ChangePwd(UAMArgs *inUAMArgs)
{
GrafPtr theSavePort;
short theItem;
OSStatus theError;
Str255 theNewPwd, theVerPwd;
CursHandle theCursor;
DialogPtr theDialog = NULL;
Boolean theDoLoop = true;
KCItemRef theKCItemRef = NULL;
Assert_(gDialogFilter != NULL);
Assert_(gLineItem != NULL);
GetPort(&theSavePort);
ParamText(inUAMArgs->Opt.pwDlg.userName, gServerName, NULL, NULL);
theDialog = UAM_NewDialog(DLOG_ChangePwd, true);
if (theDialog == NULL)
{
UAM_ReportError(resNotFound);
return(resNotFound);
}
//
//Set up the line at the top of the dialog.
//
UAM_SetUpUserItem(theDialog, DITEM_LineItem, gLineItem, userItem);
//
//All three fields in this dialog are bullet protected.
//
UAM_SetBulletItem(theDialog, DITEM_OldPassword, UAM_CLRTXTPWDLEN);
UAM_SetBulletItem(theDialog, DITEM_NewPassword, UAM_CLRTXTPWDLEN);
UAM_SetBulletItem(theDialog, DITEM_VerifyPwd, UAM_CLRTXTPWDLEN);
if (inUAMArgs->Opt.pwDlg.password[0] != 0)
{
UAM_SetBulletText(
theDialog,
DITEM_OldPassword,
inU
|