X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FSetupBrowserDxe%2FPresentation.c;h=4cd71e5d440d04e8653243361d9d1b705045c99d;hb=253616154506e17ebd02c076f240748f57e36ac2;hp=80e3a71edd6c2fc995f33cabe74a0843e662bd3f;hpb=7538d53684792266c37e91f11a3ce2b7fb1e32d9;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c index 80e3a71edd..4cd71e5d44 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c @@ -1,7 +1,7 @@ /** @file Utility functions for UI presentation. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.
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 @@ -468,7 +468,6 @@ DisplayForm ( CHAR16 *StringPtr; UINT16 MenuItemCount; EFI_HII_HANDLE Handle; - BOOLEAN Suppress; EFI_SCREEN_DESCRIPTOR LocalScreen; UINT16 Width; UINTN ArrayEntry; @@ -478,6 +477,7 @@ DisplayForm ( UINT16 NumberOfLines; EFI_STATUS Status; UI_MENU_OPTION *MenuOption; + UINT16 GlyphWidth; Handle = Selection->Handle; MenuItemCount = 0; @@ -521,17 +521,7 @@ DisplayForm ( while (!IsNull (&Selection->Form->StatementListHead, Link)) { Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link); - if (Statement->SuppressExpression != NULL) { - Suppress = Statement->SuppressExpression->Result.Value.b; - } else { - Suppress = FALSE; - } - - if (Statement->DisableExpression != NULL) { - Suppress = (BOOLEAN) (Suppress || Statement->DisableExpression->Result.Value.b); - } - - if (!Suppress) { + if (EvaluateExpressionList(Statement->Expression, FALSE, NULL, NULL) <= ExpressGrayOut) { StringPtr = GetToken (Statement->Prompt, Handle); ASSERT (StringPtr != NULL); @@ -539,7 +529,8 @@ DisplayForm ( NumberOfLines = 1; ArrayEntry = 0; - for (; GetLineByWidth (StringPtr, Width, &ArrayEntry, &OutputString) != 0x0000;) { + GlyphWidth = 1; + for (; GetLineByWidth (StringPtr, Width, &GlyphWidth,&ArrayEntry, &OutputString) != 0x0000;) { // // If there is more string to process print on the next row and increment the Skip value // @@ -554,7 +545,7 @@ DisplayForm ( // We are NOT!! removing this StringPtr buffer via FreePool since it is being used in the menuoptions, we will do // it in UiFreeMenu. // - MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Statement, NumberOfLines, MenuItemCount); + MenuOption = UiAddMenuOption (StringPtr, Selection->Handle, Selection->Form, Statement, NumberOfLines, MenuItemCount); MenuItemCount++; if (MenuOption->IsQuestion && !MenuOption->ReadOnly) { @@ -611,6 +602,7 @@ InitializeBrowserStrings ( gSaveChanges = GetToken (STRING_TOKEN (SAVE_CHANGES), gHiiHandle); gOptionMismatch = GetToken (STRING_TOKEN (OPTION_MISMATCH), gHiiHandle); gFormSuppress = GetToken (STRING_TOKEN (FORM_SUPPRESSED), gHiiHandle); + gProtocolNotFound = GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND), gHiiHandle); return ; } @@ -651,6 +643,7 @@ FreeBrowserStrings ( FreePool (gSaveChanges); FreePool (gOptionMismatch); FreePool (gFormSuppress); + FreePool (gProtocolNotFound); return ; } @@ -1220,11 +1213,8 @@ ProcessCallBackFunction ( // // Check whether Statement is disabled. // - if (Statement->DisableExpression != NULL) { - Status = EvaluateExpression (Selection->FormSet, Selection->Form, Statement->DisableExpression); - if (!EFI_ERROR (Status) && - (Statement->DisableExpression->Result.Type == EFI_IFR_TYPE_BOOLEAN) && - (Statement->DisableExpression->Result.Value.b)) { + if (Statement->Expression != NULL) { + if (EvaluateExpressionList(Statement->Expression, TRUE, Selection->FormSet, Selection->Form) == ExpressDisable) { continue; } } @@ -1248,45 +1238,52 @@ ProcessCallBackFunction ( &ActionRequest ); if (!EFI_ERROR (Status)) { - switch (ActionRequest) { - case EFI_BROWSER_ACTION_REQUEST_RESET: - gResetRequired = TRUE; - Selection->Action = UI_ACTION_EXIT; - break; + // + // Only for EFI_BROWSER_ACTION_CHANGED need to handle this ActionRequest. + // + if (Action == EFI_BROWSER_ACTION_CHANGED) { + switch (ActionRequest) { + case EFI_BROWSER_ACTION_REQUEST_RESET: + DiscardFormIsRequired = TRUE; + gResetRequired = TRUE; + Selection->Action = UI_ACTION_EXIT; + break; - case EFI_BROWSER_ACTION_REQUEST_SUBMIT: - SubmitFormIsRequired = TRUE; - Selection->Action = UI_ACTION_EXIT; - break; + case EFI_BROWSER_ACTION_REQUEST_SUBMIT: + SubmitFormIsRequired = TRUE; + Selection->Action = UI_ACTION_EXIT; + break; - case EFI_BROWSER_ACTION_REQUEST_EXIT: - Selection->Action = UI_ACTION_EXIT; - break; + case EFI_BROWSER_ACTION_REQUEST_EXIT: + DiscardFormIsRequired = TRUE; + Selection->Action = UI_ACTION_EXIT; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT: - SubmitFormIsRequired = TRUE; - SettingLevel = FormLevel; - NeedExit = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT: + SubmitFormIsRequired = TRUE; + SettingLevel = FormLevel; + NeedExit = TRUE; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT: - DiscardFormIsRequired = TRUE; - SettingLevel = FormLevel; - NeedExit = TRUE; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD_EXIT: + DiscardFormIsRequired = TRUE; + SettingLevel = FormLevel; + NeedExit = TRUE; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY: - SubmitFormIsRequired = TRUE; - SettingLevel = FormLevel; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_APPLY: + SubmitFormIsRequired = TRUE; + SettingLevel = FormLevel; + break; - case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD: - DiscardFormIsRequired = TRUE; - SettingLevel = FormLevel; - break; + case EFI_BROWSER_ACTION_REQUEST_FORM_DISCARD: + DiscardFormIsRequired = TRUE; + SettingLevel = FormLevel; + break; - default: - break; + default: + break; + } } // @@ -1294,7 +1291,7 @@ ProcessCallBackFunction ( // "retrieve" should update to the question's temp buffer. // if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { - SetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE); + SetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer); } } else { // @@ -1302,7 +1299,7 @@ ProcessCallBackFunction ( // "retrieve", should restore the question's value. // if (Action == EFI_BROWSER_ACTION_CHANGING || Action == EFI_BROWSER_ACTION_RETRIEVE) { - GetQuestionValue(Selection->FormSet, Selection->Form, Statement, TRUE); + GetQuestionValue(Selection->FormSet, Selection->Form, Statement, GetSetValueWithEditBuffer); } if (Status == EFI_UNSUPPORTED) { @@ -1329,6 +1326,57 @@ ProcessCallBackFunction ( return Status; } +/** + Call the retrieve type call back function for one question to get the initialize data. + + This function only used when in the initialize stage, because in this stage, the + Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead. + + @param ConfigAccess The config access protocol produced by the hii driver. + @param Statement The Question which need to call. + + @retval EFI_SUCCESS The call back function excutes successfully. + @return Other value if the call back function failed to excute. +**/ +EFI_STATUS +ProcessRetrieveForQuestion ( + IN EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess, + IN FORM_BROWSER_STATEMENT *Statement + ) +{ + EFI_STATUS Status; + EFI_BROWSER_ACTION_REQUEST ActionRequest; + EFI_HII_VALUE *HiiValue; + EFI_IFR_TYPE_VALUE *TypeValue; + + Status = EFI_SUCCESS; + ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + + if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) { + return EFI_UNSUPPORTED; + } + + HiiValue = &Statement->HiiValue; + TypeValue = &HiiValue->Value; + if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) { + // + // For OrderedList, passing in the value buffer to Callback() + // + TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue; + } + + ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE; + Status = ConfigAccess->Callback ( + ConfigAccess, + EFI_BROWSER_ACTION_RETRIEVE, + Statement->QuestionId, + HiiValue->Type, + TypeValue, + &ActionRequest + ); + return Status; +} + /** The worker function that send the displays to the screen. On output, the selection made by user is returned. @@ -1392,6 +1440,15 @@ SetupBrowser ( InsertTailList (&gBrowserFormSetList, &gOldFormSet->Link); do { + // + // IFR is updated, force to reparse the IFR binary + // + if (mHiiPackageListUpdated) { + Selection->Action = UI_ACTION_REFRESH_FORMSET; + mHiiPackageListUpdated = FALSE; + break; + } + // // Initialize Selection->Form // @@ -1419,13 +1476,7 @@ SetupBrowser ( // Check Form is suppressed. // if (Selection->Form->SuppressExpression != NULL) { - Status = EvaluateExpression (Selection->FormSet, Selection->Form, Selection->Form->SuppressExpression); - if (EFI_ERROR (Status) || (Selection->Form->SuppressExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN)) { - Status = EFI_INVALID_PARAMETER; - goto Done; - } - - if (Selection->Form->SuppressExpression->Result.Value.b) { + if (EvaluateExpressionList(Selection->Form->SuppressExpression, TRUE, Selection->FormSet, Selection->Form) == ExpressSuppress) { // // Form is suppressed. // @@ -1438,11 +1489,6 @@ SetupBrowser ( } } - // - // Reset FormPackage update flag - // - mHiiPackageListUpdated = FALSE; - // // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN // for each question with callback flag. @@ -1526,15 +1572,9 @@ SetupBrowser ( gResetRequired = TRUE; } - // - // Reset FormPackage update flag - // - mHiiPackageListUpdated = FALSE; - if ((ConfigAccess != NULL) && ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && (Statement->Operand != EFI_IFR_PASSWORD_OP)) { - Status = ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGING, FALSE); if (Statement->Operand == EFI_IFR_REF_OP && Selection->Action != UI_ACTION_EXIT) { // @@ -1555,17 +1595,10 @@ SetupBrowser ( Selection->QuestionId = 0; } } - } - // - // Check whether Form Package has been updated during Callback - // - if (mHiiPackageListUpdated && (Selection->Action == UI_ACTION_REFRESH_FORM)) { - // - // Force to reparse IFR binary of target Formset - // - mHiiPackageListUpdated = FALSE; - Selection->Action = UI_ACTION_REFRESH_FORMSET; + if (!EFI_ERROR (Status) && Statement->Operand != EFI_IFR_REF_OP) { + ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE); + } } }