Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Password mask issue

58 views
Skip to first unread message

mehm...@yahoo.com

unread,
Jan 16, 2009, 7:18:37 PM1/16/09
to
I am trying to create a login panel for test purposes, and it opens
whenever the Test GUI is first opened and it requests a valid username
and password entry before opening the test GUI. I am using the
pwctrl.fp and the PasswordCtrl_ConvertFromString command to mask the
password string in the password entry text box, but the password is
not getting masked with the "*" character as I was expecting. I tried
following the password example project, but with no success. I have
attached the code snippets to see if anyone can point out the error in
my ways. Thanks for any help.

/
********************************************************************************
* Login() *
* Purpose: This function opens a login panel and waits for the login
input. *

********************************************************************************/
int Login()
{
int iMaxPasswordLength = 25;
char maskChar[2] = "*";

giLoginPanel = LoadPanel(0, "mainTestGui.uir", LOGIN);

/* Convert a string control into a password control! */
giPasswordCtrlID = PasswordCtrl_ConvertFromString (giLoginPanel,
LOGIN_PASSWORD);

PasswordCtrl_SetAttribute (giLoginPanel, giPasswordCtrlID,
ATTR_PASSWORD_MASK_CHARACTER, maskChar);
PasswordCtrl_SetAttribute (giLoginPanel, giPasswordCtrlID,
ATTR_PASSWORD_MAX_LENGTH, iMaxPasswordLength);

ProcessDrawEvents();

// Install callback functions
InstallCtrlCallback (giLoginPanel, LOGIN_USERNAME, Clb_LoginData,
0);
InstallCtrlCallback (giLoginPanel, LOGIN_PASSWORD, Clb_LoginData,
0);
InstallCtrlCallback (giLoginPanel, LOGIN_OK, Clb_LoginData, 0);

SetActiveCtrl (giLoginPanel, LOGIN_USERNAME);

// open the login data panel
InstallPopup (giLoginPanel);

// Start processing panel events.
giRunLogin = RunUserInterface();

// Discard panel after it has been closed.
DiscardPanel(giLoginPanel);

return 0;
}

/*
* Clb_LoginData()
*
* Purpose:
* This callback function handles login entry inputs.
*/
int CVICALLBACK Clb_LoginData(int panel, int control, int event, void
*callbackData, int eventData1, int eventData2)
{
// Local variables
int iValidData = 0;
char cUserName[50] = "\0";
char cPassWord[50] = "\0";
char cUN1[50] = "\0";
char cPW1[50] = "\0";

switch (event)
{
case EVENT_COMMIT:

switch (control)
{
case LOGIN_OK:

// get the entered login information
GetCtrlVal (giLoginPanel, LOGIN_USERNAME, cUserName);
GetCtrlVal (giLoginPanel, LOGIN_PASSWORD, cPassWord);

// get the correct login information from the ini file
Ini_GetStringIntoBuffer(gIniText,"Login","UN1", cUN1, sizeof
(cUN1));
Ini_GetStringIntoBuffer(gIniText,"Login","PW1", cPW1, sizeof
(cPW1));

// compare the login that was entered to the login information
from the ini file
if (strcmp(cUserName, cUN1) == 0 && strcmp(cPassWord, cPW1) == 0)
iValidData = 1;
// if the data compares, then close the login panel and continue
to the test
if (iValidData)
// Close scan UUT data panel
QuitUserInterface (giRunLogin);
else
{ // else clear out the information and enter it again
SetCtrlVal (giLoginPanel, LOGIN_USERNAME, "");
SetCtrlVal (giLoginPanel, LOGIN_PASSWORD, "");
SetActiveCtrl (giLoginPanel, LOGIN_USERNAME);
SetCtrlAttribute (giLoginPanel, LOGIN_OK, ATTR_DIMMED, 1);
}
break;

case LOGIN_USERNAME:

// Advance to the next field if the username length is greater
than 0.
GetCtrlVal (giLoginPanel, LOGIN_USERNAME, cUserName);

if(strlen(cUserName))
{
// Select CID SN field as active
SetActiveCtrl (giLoginPanel, LOGIN_PASSWORD);
}
else
{
SetCtrlVal (giLoginPanel, LOGIN_USERNAME, "");
SetCtrlAttribute (giLoginPanel, LOGIN_OK, ATTR_DIMMED, 1);
SetActiveCtrl (giLoginPanel, LOGIN_USERNAME);
ProcessDrawEvents();
}
break;

case LOGIN_PASSWORD:

// Advance to the next field if the password field is not
empty.
GetCtrlVal (giLoginPanel, LOGIN_PASSWORD, cPassWord);

if(strlen(cPassWord))
{
// Un-dim the OK button
SetCtrlAttribute (giLoginPanel, LOGIN_OK, ATTR_DIMMED, 0);
// Set the OK button as active
SetActiveCtrl (giLoginPanel, LOGIN_OK);
}
else
{
SetCtrlVal (giLoginPanel, LOGIN_PASSWORD, "");
SetCtrlAttribute (giLoginPanel, LOGIN_OK, ATTR_DIMMED, 1);
SetActiveCtrl (giLoginPanel, LOGIN_PASSWORD);
ProcessDrawEvents();
}
break;
}
break;
}
return 0;
}

mike...@comcast.net

unread,
Jan 21, 2009, 6:10:21 PM1/21/09
to

I found that I had to include the "PasswordCtrl_ConvertFromString"
inside the Callback function for it to work, it doesn't work if it's
located outside of the Callback function.

0 new messages