]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Application/UiApp/FrontPageCustomizedUi.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Application / UiApp / FrontPageCustomizedUi.c
CommitLineData
c9802c45
ED
1/** @file\r
2\r
3 This library class defines a set of interfaces to customize Ui module\r
4\r
5Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
c9802c45
ED
7\r
8**/\r
9#include <Uefi.h>\r
10#include <Protocol/HiiConfigAccess.h>\r
11#include <Library/BaseLib.h>\r
12#include <Library/MemoryAllocationLib.h>\r
15b52294 13#include "FrontPage.h"\r
c9802c45
ED
14#include "FrontPageCustomizedUiSupport.h"\r
15\r
15b52294
JY
16extern FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate;\r
17\r
c9802c45
ED
18/**\r
19 Customize menus in the page.\r
20\r
21 @param[in] HiiHandle The HII Handle of the form to update.\r
22 @param[in] StartOpCodeHandle The context used to insert opcode.\r
23 @param[in] CustomizePageType The page type need to be customized.\r
24\r
25**/\r
26VOID\r
27UiCustomizeFrontPage (\r
28 IN EFI_HII_HANDLE HiiHandle,\r
29 IN VOID *StartOpCodeHandle\r
30 )\r
31{\r
32 //\r
33 // Create "Select Language" menu with Oneof opcode.\r
34 //\r
35 UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle);\r
36\r
37 //\r
38 // Create empty line.\r
39 //\r
40 UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);\r
41\r
42 //\r
43 // Find third party drivers which need to be shown in the front page.\r
44 //\r
45 UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle);\r
46\r
47 //\r
48 // Create empty line.\r
49 //\r
50 UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);\r
51\r
52 //\r
53 // Create "Continue" menu.\r
54 //\r
55 UiCreateContinueMenu(HiiHandle, StartOpCodeHandle);\r
56\r
57 //\r
58 // Create reset menu.\r
59 //\r
60 UiCreateResetMenu(HiiHandle, StartOpCodeHandle);\r
61}\r
62\r
63/**\r
64 This function processes the results of changes in configuration.\r
65\r
66\r
67 @param HiiHandle Points to the hii handle for this formset.\r
68 @param Action Specifies the type of action taken by the browser.\r
69 @param QuestionId A unique value which is sent to the original exporting driver\r
70 so that it can identify the type of data to expect.\r
71 @param Type The type of value for the question.\r
72 @param Value A pointer to the data being sent to the original exporting driver.\r
73 @param ActionRequest On return, points to the action requested by the callback function.\r
74\r
75 @retval EFI_SUCCESS The callback successfully handled the action.\r
76 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r
77 @retval EFI_DEVICE_ERROR The variable could not be saved.\r
78 @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.\r
79\r
80**/\r
81EFI_STATUS\r
82UiFrontPageCallbackHandler (\r
83 IN EFI_HII_HANDLE HiiHandle,\r
84 IN EFI_BROWSER_ACTION Action,\r
85 IN EFI_QUESTION_ID QuestionId,\r
86 IN UINT8 Type,\r
87 IN EFI_IFR_TYPE_VALUE *Value,\r
88 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
89 )\r
90{\r
91 EFI_STATUS Status;\r
92\r
93 if (UiSupportLibCallbackHandler (HiiHandle, Action, QuestionId, Type, Value, ActionRequest, &Status)) {\r
94 return Status;\r
95 }\r
96\r
97 return EFI_UNSUPPORTED;\r
98}\r
99\r
100/**\r
101 Update the banner string in the front page.\r
102\r
103 Current layout for the banner string like below:\r
104 PS: Totally only 5 lines of banner supported.\r
105\r
106 Line 1: Left BannerStr RightBannerStr\r
107 Line 2: Left BannerStr RightBannerStr\r
108 Line 3: Left BannerStr RightBannerStr\r
109 Line 4: Left BannerStr RightBannerStr\r
110 Line 5: Left BannerStr RightBannerStr\r
111 <EmptyLine>\r
112 First menu in front page.\r
113 ...\r
114\r
115 @param LineIndex The line index of the banner need to check.\r
116 @param LeftOrRight The left or right banner need to check.\r
117 @param BannerStr Banner string need to update.\r
118 Input the current string and user can update\r
119 it and return the new string.\r
120\r
121**/\r
122VOID\r
123UiCustomizeFrontPageBanner (\r
124 IN UINTN LineIndex,\r
125 IN BOOLEAN LeftOrRight,\r
126 IN OUT EFI_STRING *BannerStr\r
127 )\r
128{\r
15b52294
JY
129 if ((LineIndex == 5) && LeftOrRight) {\r
130 // Update STR_CUSTOMIZE_BANNER_LINE5_LEFT\r
131 if (PcdGetBool(PcdTestKeyUsed)) {\r
132 if (BannerStr != NULL) {\r
133 FreePool(*BannerStr);\r
134 }\r
135 *BannerStr = HiiGetString(gFrontPagePrivate.HiiHandle, STRING_TOKEN(STR_TEST_KEY_USED), NULL);\r
136 }\r
137 }\r
138 return;\r
c9802c45 139}\r