From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8362421B06E9B for ; Mon, 14 Aug 2017 20:06:18 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 14 Aug 2017 20:08:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,376,1498546800"; d="scan'208";a="300158148" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga004.fm.intel.com with ESMTP; 14 Aug 2017 20:08:41 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao Date: Tue, 15 Aug 2017 11:08:00 +0800 Message-Id: <1502766480-258908-4-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1502766480-258908-1-git-send-email-dandan.bi@intel.com> References: <1502766480-258908-1-git-send-email-dandan.bi@intel.com> Subject: [patch 3/3] MdeModulePkg/DriverSample: Add sample case for popup protocol X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Aug 2017 03:06:18 -0000 Add one sample case about how to use HiiPopup protocol to draw message box. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Universal/DriverSampleDxe/DriverSample.c | 29 ++++++++++++++++++++++ .../Universal/DriverSampleDxe/DriverSample.h | 2 ++ .../Universal/DriverSampleDxe/DriverSampleDxe.inf | 1 + MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr | 8 +++++- .../Universal/DriverSampleDxe/VfrStrings.uni | 6 +++++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index f103b9c..bbd9713 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -1098,10 +1098,13 @@ DriverCallback ( EFI_STRING Results; UINT32 ProgressErr; CHAR16 *TmpStr; UINTN Index; UINT64 BufferValue; + EFI_HII_POPUP_SELECTION UserSelection; + + UserSelection = 0xFF; if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))|| (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } @@ -1617,10 +1620,26 @@ DriverCallback ( Status = EFI_SUCCESS; break; } break; + case 0x1330: + Status = mPrivateData->HiiPopup->CreatePopup ( + mPrivateData->HiiPopup, + EfiHiiPopupStyleInfo, + EfiHiiPopupTypeYesNo, + mPrivateData->HiiHandle[0], + STRING_TOKEN (STR_POPUP_STRING), + &UserSelection + ); + if (!EFI_ERROR (Status)) { + if (UserSelection == EfiHiiPopupSelectionYes) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + } + break; + default: break; } break; @@ -1676,10 +1695,11 @@ DriverSampleInit ( EFI_HII_DATABASE_PROTOCOL *HiiDatabase; EFI_HII_STRING_PROTOCOL *HiiString; EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; + EFI_HII_POPUP_PROTOCOL *PopupHandler; CHAR16 *NewString; UINTN BufferSize; DRIVER_SAMPLE_CONFIGURATION *Configuration; BOOLEAN ActionFlag; EFI_STRING ConfigRequestHdr; @@ -1761,10 +1781,19 @@ DriverSampleInit ( if (EFI_ERROR (Status)) { return Status; } mPrivateData->HiiKeywordHandler = HiiKeywordHandler; + // + // Locate HiiPopup protocol + // + Status = gBS->LocateProtocol (&gEfiHiiPopupProtocolGuid, NULL, (VOID **) &PopupHandler); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiPopup = PopupHandler; + Status = gBS->InstallMultipleProtocolInterfaces ( &DriverHandle[0], &gEfiDevicePathProtocolGuid, &mHiiVendorDevicePath0, &gEfiHiiConfigAccessProtocolGuid, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h index 6c97239..94c1534 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -31,10 +31,11 @@ Revision History #include #include #include #include #include +#include #include #include #include #include @@ -96,10 +97,11 @@ typedef struct { // EFI_HII_DATABASE_PROTOCOL *HiiDatabase; EFI_HII_STRING_PROTOCOL *HiiString; EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; + EFI_HII_POPUP_PROTOCOL *HiiPopup; EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; // // Produced protocol diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf index 4233e63..c741089 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf @@ -91,10 +91,11 @@ gEfiFormBrowser2ProtocolGuid ## CONSUMES gEfiHiiDatabaseProtocolGuid ## CONSUMES gEfiSimpleTextInputExProtocolGuid ## SOMETIMES_CONSUMES gEdkiiFormBrowserExProtocolGuid ## CONSUMES gEfiConfigKeywordHandlerProtocolGuid ## CONSUMES + gEfiHiiPopupProtocolGuid ## CONSUMES [Depex] gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid [UserExtensions.TianoCore."ExtraFiles"] diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index 4bdaf76..1024d4a 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -474,11 +474,17 @@ formset flags = INTERACTIVE, minimum = 0, maximum = 255, default = 18, endnumeric; - + + text + help = STRING_TOKEN(STR_POPUP_TEST_HELP), + text = STRING_TOKEN(STR_POPUP_TEST_PROMPT), + flags = INTERACTIVE, + key = 0x1330; + goto 2, prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage // this too has no end-op and basically it's a jump to a form ONLY help = STRING_TOKEN(STR_GOTO_HELP); goto 3, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 8d24a47..c6ff8fa 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -265,10 +265,16 @@ #language fr-FR "" #string STR_SUBMITTED_CALLBACK_TEST_PROMPT #language en-US "Submitted callback test" #language fr-FR "Submitted callback test" #string STR_SUBMITTED_CALLBACK_TEST_HELP #language en-US "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered" #language fr-FR "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered" +#string STR_POPUP_TEST_PROMPT #language en-US "Select it to invoke Hii Popup Protocol" + #language fr-FR "Select it to invoke Hii Popup Protocol" +#string STR_POPUP_TEST_HELP #language en-US "Select this question will pop up a message box, then user can decide whether exit curret form or not" + #language fr-FR "Select this question will pop up a message box, then user can decide whether exit curret form or not" +#string STR_POPUP_STRING #language en-US "Exit current form now?" + #language fr-FR "Exit current form now?" // Boot Order #string STR_BOOT_TITLE #language en-US "Boot" #string STR_BOOT_OPTIONS #language en-US "Boot Order" #string STR_BOOT_OPTION1 #language en-US "IDE HDD" #string STR_BOOT_OPTION2 #language en-US "ATAPI CD" -- 1.9.5.msysgit.1