/** @file
Implementation for handling the User Interface option processing.
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Setup.h"
/**
Process Question Config.
@param Selection The UI menu selection.
@param Question The Question to be peocessed.
@retval EFI_SUCCESS Question Config process success.
@retval Other Question Config process fail.
**/
)
{
if (Question->QuestionConfig == 0) {
return EFI_SUCCESS;
}
//
// Get <ConfigResp>
//
if (ConfigResp == NULL) {
return EFI_NOT_FOUND;
}
//
// Send config to Configuration Driver
//
if (ConfigAccess == NULL) {
return EFI_UNSUPPORTED;
}
);
return Status;
}
/**
Search an Option of a Question by its value.
@param Question The Question
@param OptionValue Value for Option to be searched.
@retval Pointer Pointer to the found Option.
@retval NULL Option not found.
**/
)
{
if ((CompareHiiValue (&Option->Value, OptionValue, &Result, NULL) == EFI_SUCCESS) && (Result == 0)) {
return Option;
}
}
return NULL;
}
/**
Return data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@retval Value The data to be returned
**/
)
{
Data = 0;
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
break;
default:
break;
}
return Data;
}
/**
Set value of a data element in an Array by its Index.
@param Array The data array.
@param Type Type of the data in this array.
@param Index Zero based index for data in this array.
@param Value The value to be set.
**/
)
{
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
break;
case EFI_IFR_TYPE_NUM_SIZE_16:
break;
case EFI_IFR_TYPE_NUM_SIZE_32:
break;
case EFI_IFR_TYPE_NUM_SIZE_64:
break;
default:
break;
}
}
/**
Print Question Value according to it's storage width and display attributes.
@param Question The Question to be printed.
@param FormattedNumber Buffer for output string.
@param BufferSize The FormattedNumber buffer size in bytes.
@retval EFI_SUCCESS Print success.
@retval EFI_BUFFER_TOO_SMALL Buffer size is not enough for formatted number.
**/
)
{
return EFI_BUFFER_TOO_SMALL;
}
case EFI_IFR_DISPLAY_INT_DEC:
switch (QuestionValue->Type) {
case EFI_IFR_NUMERIC_SIZE_1:
break;
case EFI_IFR_NUMERIC_SIZE_2:
break;
case EFI_IFR_NUMERIC_SIZE_4:
break;
case EFI_IFR_NUMERIC_SIZE_8:
default:
break;
}
if (Value < 0) {
Format = L"-%ld";
} else {
Format = L"%ld";
}
break;
case EFI_IFR_DISPLAY_UINT_DEC:
Format = L"%ld";
break;
case EFI_IFR_DISPLAY_UINT_HEX:
Format = L"%lx";
break;
default:
return EFI_UNSUPPORTED;
break;
}
return EFI_SUCCESS;
}
/**
Password may be stored as encrypted by Configuration Driver. When change a
password, user will be challenged with old password. To validate user input old
password, we will send the clear text to Configuration Driver via Callback().
Configuration driver is responsible to check the passed in password and return
the validation result. If validation pass, state machine in password Callback()
will transit from BROWSER_STATE_VALIDATE_PASSWORD to BROWSER_STATE_SET_PASSWORD.
After user type in new password twice, Callback() will be invoked to send the
new password to Configuration Driver.
@param Selection Pointer to UI_MENU_SELECTION.
@param MenuOption The MenuOption for this password Question.
@param String The clear text of password.
@retval EFI_NOT_AVAILABLE_YET Callback() request to terminate password input.
@return In state of BROWSER_STATE_VALIDATE_PASSWORD:
@retval EFI_SUCCESS Password correct, Browser will prompt for new
password.
@retval EFI_NOT_READY Password incorrect, Browser will show error
message.
@retval Other Browser will do nothing.
@return In state of BROWSER_STATE_SET_PASSWORD:
@retval EFI_SUCCESS Set password success.
@retval Other Set password failed.
**/
)
{
if (ConfigAccess == NULL) {
return EFI_UNSUPPORTED;
}
//
// Prepare password string in HII database
//
} else {
IfrTypeValue.string = 0;
}
//
// Send password to Configuration Driver for validation
//
);
//
// Remove password string from HII database
//
}
return Status;
}
/**
Display error message for invalid password.
**/
)
{
//
// Invalid password, prompt error message
//
do {
}
/**
Process a Question's Option (whether selected or un-selected).
@param Selection Pointer to UI_MENU_SELECTION.
@param MenuOption The MenuOption for this Question.
@param Selected TRUE: if Question is selected.
@param OptionString Pointer of the Option String to be displayed.
@retval EFI_SUCCESS Question Option process success.
@retval Other Question Option process fail.
**/
)
{
*OptionString = NULL;
StringId = 0;
case EFI_IFR_ORDERED_LIST_OP:
//
// Check whether there are Options of this OrderedList
//
break;
}
//
// Initialize Option value array
//
}
if (Selected) {
//
// Go ask for input
//
} else {
//
// We now know how many strings we will have, so we can allocate the
// space required for the array or strings.
//
ASSERT (*OptionString);
//
// Values for the options in ordered lists should never be a 0
//
break;
}
if (OneOfOption == NULL) {
//
// Show error message
//
do {
//
// The initial value of the orderedlist is invalid, force to be valid value
//
Index2 = 0;
Index2++;
}
FreePool (*OptionString);
*OptionString = NULL;
return EFI_NOT_FOUND;
}
//
// This option is suppressed
//
}
if (!Suppress) {
}
}
}
break;
case EFI_IFR_ONE_OF_OP:
//
// Check whether there are Options of this OneOf
//
break;
}
if (Selected) {
//
// Go ask for input
//
} else {
ASSERT (*OptionString);
if (OneOfOption == NULL) {
//
// Show error message
//
do {
//
// Force the Question value to be valid
//
break;
}
}
FreePool (*OptionString);
*OptionString = NULL;
return EFI_NOT_FOUND;
}
((EvaluateExpressionList(OneOfOption->SuppressExpression, FALSE, NULL, NULL) == ExpressSuppress))) {
//
// This option is suppressed
//
} else {
}
if (Suppress) {
//
// Current selected option happen to be suppressed,
// enforce to select on a non-suppressed option
//
break;
}
}
}
if (!Suppress) {
}
}
break;
case EFI_IFR_CHECKBOX_OP:
ASSERT (*OptionString);
if (Selected) {
//
// Since this is a BOOLEAN operation, flip it upon selection
//
//
// Perform inconsistent check
//
Status = ValidateQuestion (Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
//
// Inconsistent check fail, restore Question Value
//
FreePool (*OptionString);
*OptionString = NULL;
return Status;
}
//
// Save Question value
//
}
if (QuestionValue->Value.b) {
} else {
}
break;
case EFI_IFR_NUMERIC_OP:
if (Selected) {
//
// Go ask for input
//
} else {
ASSERT (*OptionString);
//
// Formatted print
//
}
break;
case EFI_IFR_DATE_OP:
if (Selected) {
//
// This is similar to numerics
//
} else {
ASSERT (*OptionString);
switch (MenuOption->Sequence) {
case 0:
UnicodeSPrint (OptionString[0] + 1, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.date.Month);
break;
case 1:
break;
case 2:
break;
}
}
break;
case EFI_IFR_TIME_OP:
if (Selected) {
//
// This is similar to numerics
//
} else {
ASSERT (*OptionString);
switch (MenuOption->Sequence) {
case 0:
break;
case 1:
UnicodeSPrint (OptionString[0] + 4, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Minute);
break;
case 2:
UnicodeSPrint (OptionString[0] + 7, 21 * sizeof (CHAR16), L"%02d", QuestionValue->Value.time.Second);
break;
}
}
break;
case EFI_IFR_STRING_OP:
if (Selected) {
Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
} else {
}
}
} else {
ASSERT (*OptionString);
*(OptionString[0]) = '_';
} else {
}
}
}
break;
case EFI_IFR_PASSWORD_OP:
if (Selected) {
//
// For interactive passwords, old password is validated by callback
//
//
// Use a NULL password to test whether old password is required
//
*StringPtr = 0;
//
// Callback is not supported, or
// Callback request to terminate password input
//
return EFI_SUCCESS;
}
//
// Old password exist, ask user for the old password
//
return Status;
}
//
// Check user input old password
//
if (Status == EFI_NOT_READY) {
//
// Typed in old password incorrect
//
PasswordInvalid ();
} else {
}
return Status;
}
}
} else {
//
// For non-interactive password, validate old password in local
//
//
// There is something there! Prompt for password
//
return Status;
}
//
// Typed in old password incorrect
//
PasswordInvalid ();
return Status;
}
}
}
//
// Ask for new password
//
//
// Reset state machine for interactive password
//
}
return Status;
}
//
// Confirm new password
//
ASSERT (TempString);
//
// Reset state machine for interactive password
//
}
return Status;
}
//
// Compare two typed-in new passwords
//
//
// Prepare the Question->HiiValue.Value.string for ValidateQuestion use.
//
} else {
}
Status = ValidateQuestion(Selection->FormSet, Selection->Form, Question, EFI_HII_EXPRESSION_INCONSISTENT_IF);
//
// Researve the Question->HiiValue.Value.string.
//
}
//
// Reset state machine for interactive password
//
} else {
//
// Researve the Question->HiiValue.Value.string.
//
HiiSetString(Selection->FormSet->HiiHandle, Question->HiiValue.Value.string, (CHAR16*)Question->BufferValue, NULL);
}
} else {
//
// Two password match, send it to Configuration Driver
//
} else {
}
}
} else {
//
// Reset state machine for interactive password
//
}
//
// Two password mismatch, prompt error message
//
do {
}
}
break;
default:
break;
}
return Status;
}
/**
Process the help string: Split StringPtr to several lines of strings stored in
FormattedString and the glyph width of each line cannot exceed gHelpBlockWidth.
@param StringPtr The entire help string.
@param FormattedString The oupput formatted string.
@param RowCount TRUE: if Question is selected.
**/
)
{
TotalRowNum = 0;
CheckedNum = 0;
//
// Get row number of the String.
//
for (Index = 0; GetLineByWidth (StringPtr, (UINT16) (gHelpBlockWidth - 1), &Index, &OutputString) != 0x0000; ) {
TotalRowNum ++;
}
for (Index = 0; GetLineByWidth (StringPtr, (UINT16) (gHelpBlockWidth - 1), &Index, &OutputString) != 0x0000; CheckedNum ++) {
CopyMem (*FormattedString + CheckedNum * gHelpBlockWidth * sizeof (CHAR16), OutputString, gHelpBlockWidth * sizeof (CHAR16));
}
return TotalRowNum;
}