Refine the save action for the browser.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15639 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Eric Dong
2014-07-08 06:04:53 +00:00
committed by ydong10
parent a6908c99aa
commit 4d4deaaccb
9 changed files with 983 additions and 262 deletions

View File

@@ -117,6 +117,12 @@ CHAR16 *gFormNotFound;
CHAR16 *gNoSubmitIf;
CHAR16 *gBrwoserError;
CHAR16 *gSaveFailed;
CHAR16 *gNoSubmitIfFailed;
CHAR16 *gSaveProcess;
CHAR16 *gSaveNoSubmitProcess;
CHAR16 *gDiscardChange;
CHAR16 *gJumpToFormSet;
CHAR16 *gCheckError;
CHAR16 *gPromptForData;
CHAR16 *gPromptForPassword;
CHAR16 *gPromptForNewPassword;
@@ -186,6 +192,12 @@ InitializeDisplayStrings (
{
mUnknownString = GetToken (STRING_TOKEN (UNKNOWN_STRING), gHiiHandle);
gSaveFailed = GetToken (STRING_TOKEN (SAVE_FAILED), gHiiHandle);
gNoSubmitIfFailed = GetToken (STRING_TOKEN (NO_SUBMIT_IF_CHECK_FAILED), gHiiHandle);
gSaveProcess = GetToken (STRING_TOKEN (DISCARD_OR_JUMP), gHiiHandle);
gSaveNoSubmitProcess = GetToken (STRING_TOKEN (DISCARD_OR_CHECK), gHiiHandle);
gDiscardChange = GetToken (STRING_TOKEN (DISCARD_OR_JUMP_DISCARD), gHiiHandle);
gJumpToFormSet = GetToken (STRING_TOKEN (DISCARD_OR_JUMP_JUMP), gHiiHandle);
gCheckError = GetToken (STRING_TOKEN (DISCARD_OR_CHECK_CHECK), gHiiHandle);
gPromptForData = GetToken (STRING_TOKEN (PROMPT_FOR_DATA), gHiiHandle);
gPromptForPassword = GetToken (STRING_TOKEN (PROMPT_FOR_PASSWORD), gHiiHandle);
gPromptForNewPassword = GetToken (STRING_TOKEN (PROMPT_FOR_NEW_PASSWORD), gHiiHandle);
@@ -216,6 +228,12 @@ FreeDisplayStrings (
FreePool (mUnknownString);
FreePool (gEmptyString);
FreePool (gSaveFailed);
FreePool (gNoSubmitIfFailed);
FreePool (gSaveProcess);
FreePool (gSaveNoSubmitProcess);
FreePool (gDiscardChange);
FreePool (gJumpToFormSet);
FreePool (gCheckError);
FreePool (gPromptForData);
FreePool (gPromptForPassword);
FreePool (gPromptForNewPassword);
@@ -3208,6 +3226,9 @@ BrowserStatusProcess (
WARNING_IF_CONTEXT EventContext;
EFI_IFR_OP_HEADER *OpCodeBuf;
EFI_STRING_ID StringToken;
CHAR16 DiscardChange;
CHAR16 JumpToFormSet;
CHAR16 *PrintString;
if (gFormData->BrowserStatus == BROWSER_SUCCESS) {
return;
@@ -3263,62 +3284,94 @@ BrowserStatusProcess (
ErrorInfo = gProtocolNotFound;
break;
case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF:
ErrorInfo = gNoSubmitIfFailed;
break;
default:
ErrorInfo = gBrwoserError;
break;
}
}
if (TimeOut == 0) {
switch (gFormData->BrowserStatus) {
case BROWSER_SUBMIT_FAIL:
case BROWSER_SUBMIT_FAIL_NO_SUBMIT_IF:
ASSERT (gUserInput != NULL);
if (gFormData->BrowserStatus == (BROWSER_SUBMIT_FAIL)) {
PrintString = gSaveProcess;
JumpToFormSet = gJumpToFormSet[0];
} else {
PrintString = gSaveNoSubmitProcess;
JumpToFormSet = gCheckError[0];
}
DiscardChange = gDiscardChange[0];
do {
CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
} else {
Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK, EmptyEventProcess, NULL, &TimeOutEvent);
ASSERT_EFI_ERROR (Status);
CreateDialog (&Key, gEmptyString, ErrorInfo, PrintString, gEmptyString, NULL);
} while (((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (DiscardChange | UPPER_LOWER_CASE_OFFSET)) &&
((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (JumpToFormSet | UPPER_LOWER_CASE_OFFSET)));
EventContext.SyncEvent = TimeOutEvent;
EventContext.TimeOut = &TimeOut;
EventContext.ErrorInfo = ErrorInfo;
if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (DiscardChange | UPPER_LOWER_CASE_OFFSET)) {
gUserInput->Action = BROWSER_ACTION_DISCARD;
} else {
gUserInput->Action = BROWSER_ACTION_GOTO;
}
break;
Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, RefreshTimeOutProcess, &EventContext, &RefreshIntervalEvent);
ASSERT_EFI_ERROR (Status);
//
// Show the dialog first to avoid long time not reaction.
//
gBS->SignalEvent (RefreshIntervalEvent);
Status = gBS->SetTimer (RefreshIntervalEvent, TimerPeriodic, ONE_SECOND);
ASSERT_EFI_ERROR (Status);
while (TRUE) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (Status) && Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
break;
}
if (Status != EFI_NOT_READY) {
continue;
}
WaitList[0] = TimeOutEvent;
WaitList[1] = gST->ConIn->WaitForKey;
Status = gBS->WaitForEvent (2, WaitList, &Index);
default:
if (TimeOut == 0) {
do {
CreateDialog (&Key, gEmptyString, ErrorInfo, gPressEnter, gEmptyString, NULL);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
} else {
Status = gBS->CreateEvent (EVT_NOTIFY_WAIT, TPL_CALLBACK, EmptyEventProcess, NULL, &TimeOutEvent);
ASSERT_EFI_ERROR (Status);
if (Index == 0) {
//
// Timeout occur, close the hoot time out event.
//
break;
}
}
}
EventContext.SyncEvent = TimeOutEvent;
EventContext.TimeOut = &TimeOut;
EventContext.ErrorInfo = ErrorInfo;
gBS->CloseEvent (TimeOutEvent);
gBS->CloseEvent (RefreshIntervalEvent);
Status = gBS->CreateEvent (EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK, RefreshTimeOutProcess, &EventContext, &RefreshIntervalEvent);
ASSERT_EFI_ERROR (Status);
//
// Show the dialog first to avoid long time not reaction.
//
gBS->SignalEvent (RefreshIntervalEvent);
Status = gBS->SetTimer (RefreshIntervalEvent, TimerPeriodic, ONE_SECOND);
ASSERT_EFI_ERROR (Status);
while (TRUE) {
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (Status) && Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
break;
}
if (Status != EFI_NOT_READY) {
continue;
}
WaitList[0] = TimeOutEvent;
WaitList[1] = gST->ConIn->WaitForKey;
Status = gBS->WaitForEvent (2, WaitList, &Index);
ASSERT_EFI_ERROR (Status);
if (Index == 0) {
//
// Timeout occur, close the hoot time out event.
//
break;
}
}
gBS->CloseEvent (TimeOutEvent);
gBS->CloseEvent (RefreshIntervalEvent);
}
break;
}
if (StringToken != 0) {
FreePool (ErrorInfo);
@@ -3357,9 +3410,9 @@ FormDisplay (
// Process the status info first.
//
BrowserStatusProcess();
if (UserInputData == NULL) {
if (gFormData->BrowserStatus != BROWSER_SUCCESS) {
//
// UserInputData == NULL, means only need to print the error info, return here.
// gFormData->BrowserStatus != BROWSER_SUCCESS, means only need to print the error info, return here.
//
return EFI_SUCCESS;
}

View File

@@ -73,6 +73,8 @@ extern CHAR16 *mUnknownString;
#define POPUP_PAD_SPACE_COUNT 5
#define POPUP_FRAME_WIDTH 2
#define UPPER_LOWER_CASE_OFFSET 0x20
//
// Display definitions
//

View File

@@ -913,6 +913,8 @@ DestroyForm (
FreePool (Form->SuppressExpression);
}
UiFreeMenuList (&Form->FormViewListHead);
//
// Free this Form
//
@@ -1227,6 +1229,7 @@ ParseOpCodes (
InitializeListHead (&FormSet->StatementListOSF);
InitializeListHead (&FormSet->StorageListHead);
InitializeListHead (&FormSet->SaveFailStorageListHead);
InitializeListHead (&FormSet->DefaultStoreListHead);
InitializeListHead (&FormSet->FormListHead);
InitializeListHead (&FormSet->ExpressionListHead);
@@ -1604,6 +1607,7 @@ ParseOpCodes (
InitializeListHead (&CurrentForm->ExpressionListHead);
InitializeListHead (&CurrentForm->StatementListHead);
InitializeListHead (&CurrentForm->ConfigRequestHead);
InitializeListHead (&CurrentForm->FormViewListHead);
CurrentForm->FormType = STANDARD_MAP_FORM_TYPE;
CopyMem (&CurrentForm->FormId, &((EFI_IFR_FORM *) OpCodeData)->FormId, sizeof (UINT16));
@@ -1645,6 +1649,8 @@ ParseOpCodes (
InitializeListHead (&CurrentForm->ExpressionListHead);
InitializeListHead (&CurrentForm->StatementListHead);
InitializeListHead (&CurrentForm->ConfigRequestHead);
InitializeListHead (&CurrentForm->FormViewListHead);
CopyMem (&CurrentForm->FormId, &((EFI_IFR_FORM *) OpCodeData)->FormId, sizeof (UINT16));
MapMethod = (EFI_IFR_FORM_MAP_METHOD *) (OpCodeData + sizeof (EFI_IFR_FORM_MAP));

View File

@@ -905,8 +905,6 @@ ProcessAction (
IN UINT16 DefaultId
)
{
EFI_STATUS Status;
//
// This is caused by use press ESC, and it should not combine with other action type.
//
@@ -928,10 +926,7 @@ ProcessAction (
}
if ((Action & BROWSER_ACTION_SUBMIT) == BROWSER_ACTION_SUBMIT) {
Status = SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope);
if (EFI_ERROR (Status)) {
PopupErrorMessage(BROWSER_SUBMIT_FAIL, NULL, NULL);
}
SubmitForm (gCurrentSelection->FormSet, gCurrentSelection->Form, gBrowserSettingScope);
}
if ((Action & BROWSER_ACTION_RESET) == BROWSER_ACTION_RESET) {
@@ -1186,7 +1181,8 @@ ProcessChangedData (
IN BROWSER_SETTING_SCOPE Scope
)
{
BOOLEAN RetValue;
BOOLEAN RetValue;
EFI_STATUS Status;
RetValue = TRUE;
switch (mFormDisplay->ConfirmDataChange()) {
@@ -1195,7 +1191,10 @@ ProcessChangedData (
break;
case BROWSER_ACTION_SUBMIT:
SubmitForm (Selection->FormSet, Selection->Form, Scope);
Status = SubmitForm (Selection->FormSet, Selection->Form, Scope);
if (EFI_ERROR (Status)) {
RetValue = FALSE;
}
break;
case BROWSER_ACTION_NONE:
@@ -1306,7 +1305,7 @@ ProcessGotoOpCode (
//
// Not found the EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL protocol.
//
PopupErrorMessage(BROWSER_PROTOCOL_NOT_FOUND, NULL, NULL);
PopupErrorMessage(BROWSER_PROTOCOL_NOT_FOUND, NULL, NULL, NULL);
FreePool (StringPtr);
return Status;
}
@@ -1383,7 +1382,7 @@ ProcessGotoOpCode (
//
// Form is suppressed.
//
PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL);
PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL);
return EFI_SUCCESS;
}
}
@@ -1630,6 +1629,12 @@ DisplayForm (
gCurrentSelection->FormId, gCurrentSelection->QuestionId);
ASSERT (CurrentMenu != NULL);
}
//
// Back up the form view history data for this form.
//
UiCopyMenuList(&gCurrentSelection->Form->FormViewListHead, &mPrivateData.FormBrowserEx2.FormViewHistoryHead);
gCurrentSelection->CurrentMenu = CurrentMenu;
//
@@ -1660,6 +1665,7 @@ DisplayForm (
// and an valid value has return.
// EFI_SUCCESS: Success shows form and get user input in UserInput paramenter.
//
ASSERT (gDisplayFormData.BrowserStatus == BROWSER_SUCCESS);
Status = mFormDisplay->FormDisplay (&gDisplayFormData, &UserInput);
if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
FreeDisplayFormData();
@@ -1849,7 +1855,7 @@ FindNextMenu (
//
if ((gBrowserSettingScope == FormLevel && IsNvUpdateRequiredForForm (Selection->Form)) ||
(gBrowserSettingScope == FormSetLevel && IsNvUpdateRequiredForFormSet(Selection->FormSet) && Scope == FormSetLevel)) {
if (!ProcessChangedData(Selection, Scope)) {
if (!ProcessChangedData(Selection, gBrowserSettingScope)) {
return FALSE;
}
}
@@ -2309,7 +2315,7 @@ SetupBrowser (
//
// Form is suppressed.
//
PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL);
PopupErrorMessage(BROWSER_FORM_SUPPRESS, NULL, NULL, NULL);
Status = EFI_NOT_FOUND;
goto Done;
}

File diff suppressed because it is too large Load Diff

View File

@@ -164,6 +164,8 @@ typedef struct {
UINTN Signature;
LIST_ENTRY Link;
LIST_ENTRY SaveFailLink;
UINT16 VarStoreId;
BROWSER_STORAGE *BrowserStorage;
@@ -174,6 +176,7 @@ typedef struct {
} FORMSET_STORAGE;
#define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
#define FORMSET_STORAGE_FROM_SAVE_FAIL_LINK(a) CR (a, FORMSET_STORAGE, SaveFailLink, FORMSET_STORAGE_SIGNATURE)
typedef union {
EFI_STRING_ID VarName;
@@ -373,6 +376,8 @@ typedef struct {
UINTN Signature;
LIST_ENTRY Link;
LIST_ENTRY SaveFailLink;
CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
UINTN SpareStrLen;
@@ -380,6 +385,7 @@ typedef struct {
BROWSER_STORAGE *Storage;
} FORM_BROWSER_CONFIG_REQUEST;
#define FORM_BROWSER_CONFIG_REQUEST_FROM_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, Link, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
#define FORM_BROWSER_CONFIG_REQUEST_FROM_SAVE_FAIL_LINK(a) CR (a, FORM_BROWSER_CONFIG_REQUEST, SaveFailLink, FORM_BROWSER_CONFIG_REQUEST_SIGNATURE)
#define FORM_BROWSER_FORM_SIGNATURE SIGNATURE_32 ('F', 'F', 'R', 'M')
#define STANDARD_MAP_FORM_TYPE 0x01
@@ -397,6 +403,7 @@ typedef struct {
BOOLEAN ModalForm; // Whether this is a modal form.
BOOLEAN Locked; // Whether this form is locked.
LIST_ENTRY FormViewListHead; // List of type FORMID_INFO is Browser View Form History List.
LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
LIST_ENTRY ConfigRequestHead; // List of configreques for all storage.
@@ -422,6 +429,8 @@ typedef struct {
typedef struct {
UINTN Signature;
LIST_ENTRY Link;
LIST_ENTRY SaveFailLink;
EFI_HII_HANDLE HiiHandle; // unique id for formset.
EFI_HANDLE DriverHandle;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
@@ -442,15 +451,20 @@ typedef struct {
FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
FORM_BROWSER_FORM *SaveFailForm; // The form which failed to save.
FORM_BROWSER_STATEMENT *SaveFailStatement; // The Statement which failed to save.
LIST_ENTRY StatementListOSF; // Statement list out side of the form.
LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
LIST_ENTRY SaveFailStorageListHead; // Storage list for the save fail storage.
LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
} FORM_BROWSER_FORMSET;
#define FORM_BROWSER_FORMSET_FROM_LINK(a) CR (a, FORM_BROWSER_FORMSET, Link, FORM_BROWSER_FORMSET_SIGNATURE)
#define FORM_BROWSER_FORMSET_FROM_SAVE_FAIL_LINK(a) CR (a, FORM_BROWSER_FORMSET, SaveFailLink, FORM_BROWSER_FORMSET_SIGNATURE)
typedef struct {
LIST_ENTRY Link;
EFI_EVENT RefreshEvent;
@@ -534,9 +548,10 @@ typedef enum {
// Get/set question value from/to.
//
typedef enum {
GetSetValueWithEditBuffer, // Get/Set question value from/to editbuffer in the storage.
GetSetValueWithEditBuffer = 0, // Get/Set question value from/to editbuffer in the storage.
GetSetValueWithBuffer, // Get/Set question value from/to buffer in the storage.
GetSetValueWithHiiDriver, // Get/Set question value from/to hii driver.
GetSetValueWithBothBuffer, // Compare the editbuffer with buffer for this question, not use the question value.
GetSetValueWithMax // Invalid value.
} GET_SET_QUESTION_VALUE_WITH;
@@ -1523,6 +1538,19 @@ UiFindParentMenu (
IN FORM_ENTRY_INFO *CurrentMenu
);
/**
Copy current Menu list to the new menu list.
@param NewMenuListHead New create Menu list.
@param CurrentMenuListHead Current Menu list.
**/
VOID
UiCopyMenuList (
OUT LIST_ENTRY *NewMenuListHead,
IN LIST_ENTRY *CurrentMenuListHead
);
/**
Search an Option of a Question by its value.
@@ -1713,13 +1741,15 @@ ValueChangedValidation (
Pop up the error info.
@param BrowserStatus The input browser status.
@param HiiHandle The HiiHandle for this error opcode.
@param OpCode The opcode use to get the erro info and timeout value.
@param ErrorString Error string used by BROWSER_NO_SUBMIT_IF.
**/
VOID
UINT32
PopupErrorMessage (
IN UINT32 BrowserStatus,
IN EFI_HII_HANDLE HiiHandle,
IN EFI_IFR_OP_HEADER *OpCode, OPTIONAL
IN CHAR16 *ErrorString
);