]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/SetupBrowserDxe/Presentation.c
Rollback patch 14537 & 14538, because patch 14537 is not tested by Laszlo Ersek,...
[mirror_edk2.git] / MdeModulePkg / Universal / SetupBrowserDxe / Presentation.c
index 6e46e0e9610df8926ab5149bc9258ef5a4973cae..4cd71e5d440d04e8653243361d9d1b705045c99d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 Utility functions for UI presentation.\r
 \r
-Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -602,6 +602,7 @@ InitializeBrowserStrings (
   gSaveChanges          = GetToken (STRING_TOKEN (SAVE_CHANGES), gHiiHandle);\r
   gOptionMismatch       = GetToken (STRING_TOKEN (OPTION_MISMATCH), gHiiHandle);\r
   gFormSuppress         = GetToken (STRING_TOKEN (FORM_SUPPRESSED), gHiiHandle);\r
+  gProtocolNotFound     = GetToken (STRING_TOKEN (PROTOCOL_NOT_FOUND), gHiiHandle);\r
   return ;\r
 }\r
 \r
@@ -642,6 +643,7 @@ FreeBrowserStrings (
   FreePool (gSaveChanges);\r
   FreePool (gOptionMismatch);\r
   FreePool (gFormSuppress);\r
+  FreePool (gProtocolNotFound);\r
   return ;\r
 }\r
 \r
@@ -1242,6 +1244,7 @@ ProcessCallBackFunction (
       if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
         switch (ActionRequest) {\r
         case EFI_BROWSER_ACTION_REQUEST_RESET:\r
+          DiscardFormIsRequired = TRUE;\r
           gResetRequired = TRUE;\r
           Selection->Action = UI_ACTION_EXIT;\r
           break;\r
@@ -1252,6 +1255,7 @@ ProcessCallBackFunction (
           break;\r
 \r
         case EFI_BROWSER_ACTION_REQUEST_EXIT:\r
+          DiscardFormIsRequired = TRUE;\r
           Selection->Action = UI_ACTION_EXIT;\r
           break;\r
 \r
@@ -1322,6 +1326,57 @@ ProcessCallBackFunction (
   return Status;\r
 }\r
 \r
+/**\r
+  Call the retrieve type call back function for one question to get the initialize data.\r
+  \r
+  This function only used when in the initialize stage, because in this stage, the \r
+  Selection->Form is not ready. For other case, use the ProcessCallBackFunction instead.\r
+\r
+  @param ConfigAccess          The config access protocol produced by the hii driver.\r
+  @param Statement             The Question which need to call.\r
+\r
+  @retval EFI_SUCCESS          The call back function excutes successfully.\r
+  @return Other value if the call back function failed to excute.  \r
+**/\r
+EFI_STATUS \r
+ProcessRetrieveForQuestion (\r
+  IN     EFI_HII_CONFIG_ACCESS_PROTOCOL  *ConfigAccess,\r
+  IN     FORM_BROWSER_STATEMENT          *Statement\r
+  )\r
+{\r
+  EFI_STATUS                      Status;\r
+  EFI_BROWSER_ACTION_REQUEST      ActionRequest;\r
+  EFI_HII_VALUE                   *HiiValue;\r
+  EFI_IFR_TYPE_VALUE              *TypeValue;\r
+\r
+  Status                = EFI_SUCCESS;\r
+  ActionRequest         = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+    \r
+  if ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) != EFI_IFR_FLAG_CALLBACK) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  HiiValue  = &Statement->HiiValue;\r
+  TypeValue = &HiiValue->Value;\r
+  if (HiiValue->Type == EFI_IFR_TYPE_BUFFER) {\r
+    //\r
+    // For OrderedList, passing in the value buffer to Callback()\r
+    //\r
+    TypeValue = (EFI_IFR_TYPE_VALUE *) Statement->BufferValue;\r
+  }\r
+    \r
+  ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
+  Status = ConfigAccess->Callback (\r
+                           ConfigAccess,\r
+                           EFI_BROWSER_ACTION_RETRIEVE,\r
+                           Statement->QuestionId,\r
+                           HiiValue->Type,\r
+                           TypeValue,\r
+                           &ActionRequest\r
+                           );\r
+  return Status;\r
+}\r
+\r
 /**\r
   The worker function that send the displays to the screen. On output,\r
   the selection made by user is returned.\r
@@ -1385,6 +1440,15 @@ SetupBrowser (
   InsertTailList (&gBrowserFormSetList, &gOldFormSet->Link);\r
 \r
   do {\r
+    //\r
+    // IFR is updated, force to reparse the IFR binary\r
+    //\r
+    if (mHiiPackageListUpdated) {\r
+      Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
+      mHiiPackageListUpdated = FALSE;\r
+      break;\r
+    }\r
+\r
     //\r
     // Initialize Selection->Form\r
     //\r
@@ -1425,11 +1489,6 @@ SetupBrowser (
       }\r
     }\r
 \r
-    //\r
-    // Reset FormPackage update flag\r
-    //\r
-    mHiiPackageListUpdated = FALSE;\r
-\r
     //\r
     // Before display new form, invoke ConfigAccess.Callback() with EFI_BROWSER_ACTION_FORM_OPEN\r
     // for each question with callback flag.\r
@@ -1513,11 +1572,6 @@ SetupBrowser (
         gResetRequired = TRUE;\r
       }\r
 \r
-      //\r
-      // Reset FormPackage update flag\r
-      //\r
-      mHiiPackageListUpdated = FALSE;\r
-\r
       if ((ConfigAccess != NULL) && \r
           ((Statement->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK) && \r
           (Statement->Operand != EFI_IFR_PASSWORD_OP)) {\r
@@ -1546,17 +1600,6 @@ SetupBrowser (
           ProcessCallBackFunction(Selection, Statement, EFI_BROWSER_ACTION_CHANGED, FALSE);\r
         }\r
       }\r
-\r
-      //\r
-      // Check whether Form Package has been updated during Callback\r
-      //\r
-      if (mHiiPackageListUpdated && (Selection->Action == UI_ACTION_REFRESH_FORM)) {\r
-        //\r
-        // Force to reparse IFR binary of target Formset\r
-        //\r
-        mHiiPackageListUpdated = FALSE;\r
-        Selection->Action = UI_ACTION_REFRESH_FORMSET;\r
-      }\r
     }\r
 \r
     //\r