* [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol @ 2017-01-16 5:57 Dandan Bi 2017-01-16 5:57 ` [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form Dandan Bi ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Dandan Bi @ 2017-01-16 5:57 UTC (permalink / raw) To: edk2-devel; +Cc: Eric Dong, Liming Gao, Jiewen Yao https://bugzilla.tianocore.org/show_bug.cgi?id=323 FileExplorer no need to search load file protocol to show files. Now remove the codes. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/FileExplorerLib/FileExplorer.c | 56 +--------------------- .../Library/FileExplorerLib/FileExplorer.h | 3 +- .../Library/FileExplorerLib/FileExplorerLib.inf | 3 +- 3 files changed, 3 insertions(+), 59 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 41a22aa..9cd366d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -1,9 +1,9 @@ /** @file File explorer related functions. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -697,23 +697,20 @@ EFI_STATUS LibFindFileSystem ( VOID ) { UINTN NoSimpleFsHandles; - UINTN NoLoadFileHandles; EFI_HANDLE *SimpleFsHandle; - EFI_HANDLE *LoadFileHandle; UINT16 *VolumeLabel; UINTN Index; EFI_STATUS Status; MENU_ENTRY *MenuEntry; FILE_CONTEXT *FileContext; UINTN OptionNumber; EFI_FILE_SYSTEM_VOLUME_LABEL *Info; NoSimpleFsHandles = 0; - NoLoadFileHandles = 0; OptionNumber = 0; // // Locate Handles that support Simple File System protocol // @@ -794,61 +791,10 @@ LibFindFileSystem ( if (NoSimpleFsHandles != 0) { FreePool (SimpleFsHandle); } - // - // Searching for handles that support Load File protocol - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiLoadFileProtocolGuid, - NULL, - &NoLoadFileHandles, - &LoadFileHandle - ); - - if (!EFI_ERROR (Status)) { - for (Index = 0; Index < NoLoadFileHandles; Index++) { - MenuEntry = LibCreateMenuEntry (); - if (NULL == MenuEntry) { - FreePool (LoadFileHandle); - return EFI_OUT_OF_RESOURCES; - } - - FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext; - FileContext->DeviceHandle = LoadFileHandle[Index]; - FileContext->IsRoot = TRUE; - - FileContext->DevicePath = DevicePathFromHandle (FileContext->DeviceHandle); - FileContext->FileName = LibDevicePathToStr (FileContext->DevicePath); - - MenuEntry->HelpString = LibDevicePathToStr (FileContext->DevicePath); - MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR); - ASSERT (MenuEntry->DisplayString != NULL); - UnicodeSPrint ( - MenuEntry->DisplayString, - MAX_CHAR, - L"Load File [%s]", - MenuEntry->HelpString - ); - MenuEntry->DisplayStringToken = HiiSetString ( - gFileExplorerPrivate.FeHiiHandle, - 0, - MenuEntry->DisplayString, - NULL - ); - - OptionNumber++; - InsertTailList (&gFileExplorerPrivate.FsOptionMenu->Head, &MenuEntry->Link); - } - } - - if (NoLoadFileHandles != 0) { - FreePool (LoadFileHandle); - } - gFileExplorerPrivate.FsOptionMenu->MenuNumber = OptionNumber; return EFI_SUCCESS; } diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index fab2052..4b5f601 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -1,9 +1,9 @@ /** @file File explorer lib. -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> 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 http://opensource.org/licenses/bsd-license.php @@ -21,11 +21,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/HiiConfigAccess.h> #include <Protocol/DevicePath.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/DevicePathToText.h> -#include <Protocol/LoadFile.h> #include <Protocol/FormBrowser2.h> #include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> #include <Library/UefiBootServicesTableLib.h> diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf index 8b4383b..c292aa2 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf @@ -1,9 +1,9 @@ ## @file # library defines a set of interfaces for how to do file explorer. # -# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR> # This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php. # @@ -53,11 +53,10 @@ [Guids] gEfiFileSystemVolumeLabelInfoIdGuid ## CONSUMES ## GUID (Indicate the information type is volume) gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode) [Protocols] gEfiSimpleFileSystemProtocolGuid ## CONSUMES - gEfiLoadFileProtocolGuid ## CONSUMES gEfiHiiConfigAccessProtocolGuid ## CONSUMES gEfiFormBrowser2ProtocolGuid ## CONSUMES gEfiDevicePathToTextProtocolGuid ## CONSUMES [Depex.common.DXE_DRIVER] -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form 2017-01-16 5:57 [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dandan Bi @ 2017-01-16 5:57 ` Dandan Bi 2017-01-18 2:50 ` Dong, Eric 2017-01-16 5:57 ` [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder Dandan Bi 2017-01-18 2:50 ` [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dong, Eric 2 siblings, 1 reply; 6+ messages in thread From: Dandan Bi @ 2017-01-16 5:57 UTC (permalink / raw) To: edk2-devel; +Cc: Eric Dong, Liming Gao, Jiewen Yao https://bugzilla.tianocore.org/show_bug.cgi?id=342 When user select and enter a directory, File Explorer will update the form based on the new folders and files in the directory. But when creating question opcodes, the question id is same with previous one and this will cause browser to show the highlight menu incorrectly. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 12 ++++++++---- MdeModulePkg/Library/FileExplorerLib/FileExplorer.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 9cd366d..315868a 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -70,10 +70,11 @@ HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath = { VOID *mLibStartOpCodeHandle = NULL; VOID *mLibEndOpCodeHandle = NULL; EFI_IFR_GUID_LABEL *mLibStartLabel = NULL; EFI_IFR_GUID_LABEL *mLibEndLabel = NULL; +UINT16 mQuestionIdUpdate; /** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @@ -1181,21 +1182,23 @@ LibUpdateFileExplorePage ( NewFileContext = NULL; LibRefreshUpdateData (); MenuOption = gFileExplorerPrivate.FsOptionMenu; + mQuestionIdUpdate += QUESTION_ID_UPDATE_STEP; + for (Index = 0; Index < MenuOption->MenuNumber; Index++) { NewMenuEntry = LibGetMenuEntry (MenuOption, Index); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; if (!NewFileContext->IsDir) { // // Create Text opcode for directory, also create Text opcode for file in FileExplorerStateBootFromFile. // HiiCreateActionOpCode ( mLibStartOpCodeHandle, - (UINT16) (FILE_OPTION_OFFSET + Index), + (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate), NewMenuEntry->DisplayStringToken, STRING_TOKEN (STR_NULL_STRING), EFI_IFR_FLAG_CALLBACK, 0 ); @@ -1207,11 +1210,11 @@ LibUpdateFileExplorePage ( mLibStartOpCodeHandle, FORM_FILE_EXPLORER_ID, NewMenuEntry->DisplayStringToken, STRING_TOKEN (STR_NULL_STRING), EFI_IFR_FLAG_CALLBACK, - (UINT16) (FILE_OPTION_OFFSET + Index) + (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate) ); } } HiiUpdateForm ( @@ -1242,11 +1245,11 @@ LibUpdateFileExplorer ( FILE_CONTEXT *NewFileContext; EFI_STATUS Status; EFI_FILE_HANDLE FileHandle; Status = EFI_SUCCESS; - FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue); + FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate; NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; if (NewFileContext->IsDir) { RemoveEntryList (&NewMenuEntry->Link); @@ -1277,11 +1280,11 @@ LibGetDevicePath ( { UINT16 FileOptionMask; MENU_ENTRY *NewMenuEntry; FILE_CONTEXT *NewFileContext; - FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue); + FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate; NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; @@ -1326,10 +1329,11 @@ ChooseFile ( if ((ChooseHandler == NULL) && (File == NULL)) { return EFI_INVALID_PARAMETER; } + mQuestionIdUpdate = 0; FileName = NULL; gFileExplorerPrivate.RetDevicePath = NULL; gFileExplorerPrivate.ChooseHandler = ChooseHandler; if (FileType != NULL) { diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index 4b5f601..ea0ad3d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -111,11 +111,11 @@ extern UINT8 FileExplorerVfrBin[]; /// Define the maximum characters that will be accepted. /// #define MAX_CHAR 480 #define FILE_OPTION_OFFSET 0x8000 #define FILE_OPTION_MASK 0x7FFF - +#define QUESTION_ID_UPDATE_STEP 200 /** This function processes the results of changes in configuration. When user select a interactive opcode, this callback will be triggered. Based on the Question(QuestionId) that triggers the callback, the corresponding -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form 2017-01-16 5:57 ` [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form Dandan Bi @ 2017-01-18 2:50 ` Dong, Eric 0 siblings, 0 replies; 6+ messages in thread From: Dong, Eric @ 2017-01-18 2:50 UTC (permalink / raw) To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Yao, Jiewen Reviewed-by: Eric Dong <eric.dong@intel.com> -----Original Message----- From: Bi, Dandan Sent: Monday, January 16, 2017 1:57 PM To: edk2-devel@lists.01.org Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> Subject: [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form https://bugzilla.tianocore.org/show_bug.cgi?id=342 When user select and enter a directory, File Explorer will update the form based on the new folders and files in the directory. But when creating question opcodes, the question id is same with previous one and this will cause browser to show the highlight menu incorrectly. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 12 ++++++++---- MdeModulePkg/Library/FileExplorerLib/FileExplorer.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 9cd366d..315868a 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -70,10 +70,11 @@ HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath = { VOID *mLibStartOpCodeHandle = NULL; VOID *mLibEndOpCodeHandle = NULL; EFI_IFR_GUID_LABEL *mLibStartLabel = NULL; EFI_IFR_GUID_LABEL *mLibEndLabel = NULL; +UINT16 mQuestionIdUpdate; /** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @@ -1181,21 +1182,23 @@ LibUpdateFileExplorePage ( NewFileContext = NULL; LibRefreshUpdateData (); MenuOption = gFileExplorerPrivate.FsOptionMenu; + mQuestionIdUpdate += QUESTION_ID_UPDATE_STEP; + for (Index = 0; Index < MenuOption->MenuNumber; Index++) { NewMenuEntry = LibGetMenuEntry (MenuOption, Index); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; if (!NewFileContext->IsDir) { // // Create Text opcode for directory, also create Text opcode for file in FileExplorerStateBootFromFile. // HiiCreateActionOpCode ( mLibStartOpCodeHandle, - (UINT16) (FILE_OPTION_OFFSET + Index), + (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate), NewMenuEntry->DisplayStringToken, STRING_TOKEN (STR_NULL_STRING), EFI_IFR_FLAG_CALLBACK, 0 ); @@ -1207,11 +1210,11 @@ LibUpdateFileExplorePage ( mLibStartOpCodeHandle, FORM_FILE_EXPLORER_ID, NewMenuEntry->DisplayStringToken, STRING_TOKEN (STR_NULL_STRING), EFI_IFR_FLAG_CALLBACK, - (UINT16) (FILE_OPTION_OFFSET + Index) + (UINT16) (FILE_OPTION_OFFSET + Index + mQuestionIdUpdate) ); } } HiiUpdateForm ( @@ -1242,11 +1245,11 @@ LibUpdateFileExplorer ( FILE_CONTEXT *NewFileContext; EFI_STATUS Status; EFI_FILE_HANDLE FileHandle; Status = EFI_SUCCESS; - FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue); + FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - + mQuestionIdUpdate; NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; if (NewFileContext->IsDir) { RemoveEntryList (&NewMenuEntry->Link); @@ -1277,11 +1280,11 @@ LibGetDevicePath ( { UINT16 FileOptionMask; MENU_ENTRY *NewMenuEntry; FILE_CONTEXT *NewFileContext; - FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue); + FileOptionMask = (UINT16) (FILE_OPTION_MASK & KeyValue) - mQuestionIdUpdate; NewMenuEntry = LibGetMenuEntry (gFileExplorerPrivate.FsOptionMenu, FileOptionMask); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; @@ -1326,10 +1329,11 @@ ChooseFile ( if ((ChooseHandler == NULL) && (File == NULL)) { return EFI_INVALID_PARAMETER; } + mQuestionIdUpdate = 0; FileName = NULL; gFileExplorerPrivate.RetDevicePath = NULL; gFileExplorerPrivate.ChooseHandler = ChooseHandler; if (FileType != NULL) { diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index 4b5f601..ea0ad3d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -111,11 +111,11 @@ extern UINT8 FileExplorerVfrBin[]; /// Define the maximum characters that will be accepted. /// #define MAX_CHAR 480 #define FILE_OPTION_OFFSET 0x8000 #define FILE_OPTION_MASK 0x7FFF - +#define QUESTION_ID_UPDATE_STEP 200 /** This function processes the results of changes in configuration. When user select a interactive opcode, this callback will be triggered. Based on the Question(QuestionId) that triggers the callback, the corresponding -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder 2017-01-16 5:57 [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dandan Bi 2017-01-16 5:57 ` [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form Dandan Bi @ 2017-01-16 5:57 ` Dandan Bi 2017-01-18 2:50 ` Dong, Eric 2017-01-18 2:50 ` [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dong, Eric 2 siblings, 1 reply; 6+ messages in thread From: Dandan Bi @ 2017-01-16 5:57 UTC (permalink / raw) To: edk2-devel; +Cc: Eric Dong, Liming Gao, Jiewen Yao https://bugzilla.tianocore.org/show_bug.cgi?id=324 Enhance the FileExplorerlib so that user can create a new file/folder through the UI page. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/FileExplorerLib/FileExplorer.c | 170 ++++++++++++++++++++- .../Library/FileExplorerLib/FileExplorer.h | 4 + .../Library/FileExplorerLib/FileExplorerString.uni | 32 +++- .../Library/FileExplorerLib/FileExplorerVfr.vfr | 56 ++++++- MdeModulePkg/Library/FileExplorerLib/FormGuid.h | 11 +- 5 files changed, 267 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 315868a..5eedad7 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -71,10 +71,28 @@ HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath = { VOID *mLibStartOpCodeHandle = NULL; VOID *mLibEndOpCodeHandle = NULL; EFI_IFR_GUID_LABEL *mLibStartLabel = NULL; EFI_IFR_GUID_LABEL *mLibEndLabel = NULL; UINT16 mQuestionIdUpdate; +CHAR16 mNewFileName[MAX_FILE_NAME_LEN]; +CHAR16 mNewFolderName[MAX_FOLDER_NAME_LEN]; +UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE; +UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE; + +/** + Create a new file or folder in current directory. + + @param FileName Point to the fileNmae or folder. + @param CreateFile CreateFile== TRUE means create a new file. + CreateFile== FALSE means create a new Folder. + +**/ +EFI_STATUS +LibCreateNewFile ( + IN CHAR16 *FileName, + IN BOOLEAN CreateFile + ); /** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @@ -173,13 +191,17 @@ LibCallback ( OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { EFI_STATUS Status; BOOLEAN NeedExit; + CHAR16 *NewFileName; + CHAR16 *NewFolderName; NeedExit = TRUE; - + NewFileName = NULL; + NewFolderName = NULL; + if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) { // // Do nothing for other UEFI Action. Only do call back when data is changed. // return EFI_UNSUPPORTED; @@ -187,11 +209,59 @@ LibCallback ( if (Action == EFI_BROWSER_ACTION_CHANGED) { if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } - + + if (QuestionId == KEY_VALUE_CREATE_FILE_AND_EXIT) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + if (!IsZeroBuffer (mNewFileName, sizeof (mNewFileName))) { + Status = LibCreateNewFile (mNewFileName,TRUE); + ZeroMem (mNewFileName,sizeof (mNewFileName)); + } + } + + if (QuestionId == KEY_VALUE_NO_CREATE_FILE_AND_EXIT) { + ZeroMem (mNewFileName,sizeof (mNewFileName)); + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + + if (QuestionId == KEY_VALUE_CREATE_FOLDER_AND_EXIT) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + if (!IsZeroBuffer (mNewFolderName, sizeof (mNewFolderName))) { + Status = LibCreateNewFile (mNewFolderName, FALSE); + ZeroMem (mNewFolderName,sizeof (mNewFolderName)); + } + } + + if (QuestionId == KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT) { + ZeroMem (mNewFolderName,sizeof (mNewFolderName)); + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + + if (QuestionId == NEW_FILE_NAME_ID) { + NewFileName = HiiGetString (gFileExplorerPrivate.FeHiiHandle, Value->string, NULL); + if (NewFileName != NULL) { + StrCpyS (mNewFileName, MAX_FILE_NAME_LEN, NewFileName); + FreePool (NewFileName); + NewFileName = NULL; + } else { + return EFI_INVALID_PARAMETER; + } + } + + if (QuestionId == NEW_FOLDER_NAME_ID) { + NewFolderName = HiiGetString (gFileExplorerPrivate.FeHiiHandle, Value->string, NULL); + if (NewFolderName != NULL) { + StrCpyS (mNewFolderName, MAX_FOLDER_NAME_LEN, NewFolderName); + FreePool (NewFolderName); + NewFolderName = NULL; + } else { + return EFI_INVALID_PARAMETER; + } + } + if (QuestionId >= FILE_OPTION_OFFSET) { LibGetDevicePath(QuestionId); // // Process the extra action. @@ -206,12 +276,12 @@ LibCallback ( } } else if (Action == EFI_BROWSER_ACTION_CHANGING) { if (Value == NULL) { return EFI_INVALID_PARAMETER; } - if (QuestionId >= FILE_OPTION_OFFSET) { + LibGetDevicePath(QuestionId); Status = LibUpdateFileExplorer (QuestionId); if (EFI_ERROR (Status)) { return Status; } } @@ -984,10 +1054,76 @@ Done: return Status; } /** + Create a new file or folder in current directory. + + @param FileName Point to the fileNmae or folder name. + @param CreateFile CreateFile== TRUE means create a new file. + CreateFile== FALSE means create a new Folder. + +**/ +EFI_STATUS +LibCreateNewFile ( + IN CHAR16 *FileName, + IN BOOLEAN CreateFile + ) +{ + EFI_FILE_HANDLE FileHandle; + EFI_FILE_HANDLE NewHandle; + EFI_HANDLE DeviceHandle; + EFI_STATUS Status; + CHAR16 *ParentName; + CHAR16 *FullFileName; + + NewHandle = NULL; + FullFileName = NULL; + + LibGetFileHandleFromDevicePath(gFileExplorerPrivate.RetDevicePath, &FileHandle, &ParentName, &DeviceHandle); + FullFileName = LibAppendFileName (ParentName, FileName); + if (FullFileName == NULL) { + return EFI_OUT_OF_RESOURCES; + } + if (CreateFile) { + Status = FileHandle->Open( + FileHandle, + &NewHandle, + FullFileName, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE, + 0 + ); + if (EFI_ERROR (Status)) { + FileHandle->Close (FileHandle); + return Status; + } + } else { + Status = FileHandle->Open( + FileHandle, + &NewHandle, + FullFileName, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE, + EFI_FILE_DIRECTORY + ); + if (EFI_ERROR (Status)) { + FileHandle->Close (FileHandle); + return Status; + } + } + + FileHandle->Close (FileHandle); + + // + // Return the DevicePath of the new created file or folder. + // + gFileExplorerPrivate.RetDevicePath = FileDevicePath (DeviceHandle, FullFileName); + + return EFI_SUCCESS; + +} + +/** Find files under current directory. All files and sub-directories in current directory will be stored in DirectoryMenu for future use. @@ -1175,23 +1311,51 @@ LibUpdateFileExplorePage ( { UINTN Index; MENU_ENTRY *NewMenuEntry; FILE_CONTEXT *NewFileContext; MENU_OPTION *MenuOption; + BOOLEAN CreateNewFile; NewMenuEntry = NULL; NewFileContext = NULL; + CreateNewFile = FALSE; LibRefreshUpdateData (); MenuOption = gFileExplorerPrivate.FsOptionMenu; mQuestionIdUpdate += QUESTION_ID_UPDATE_STEP; for (Index = 0; Index < MenuOption->MenuNumber; Index++) { NewMenuEntry = LibGetMenuEntry (MenuOption, Index); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; + if (!NewFileContext->IsRoot && !CreateNewFile) { + HiiCreateGotoOpCode ( + mLibStartOpCodeHandle, + FORM_ADD_NEW_FILE_ID, + STRING_TOKEN (STR_NEW_FILE), + STRING_TOKEN (STR_NEW_FILE_HELP), + EFI_IFR_FLAG_CALLBACK, + (UINT16) (mNewFileQuestionId++) + ); + HiiCreateGotoOpCode ( + mLibStartOpCodeHandle, + FORM_ADD_NEW_FOLDER_ID, + STRING_TOKEN (STR_NEW_FOLDER), + STRING_TOKEN (STR_NEW_FOLDER_HELP), + EFI_IFR_FLAG_CALLBACK, + (UINT16) (mNewFolderQuestionId++) + ); + HiiCreateTextOpCode( + mLibStartOpCodeHandle, + STRING_TOKEN (STR_NULL_STRING), + STRING_TOKEN (STR_NULL_STRING), + 0 + ); + CreateNewFile = TRUE; + } + if (!NewFileContext->IsDir) { // // Create Text opcode for directory, also create Text opcode for file in FileExplorerStateBootFromFile. // HiiCreateActionOpCode ( diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index ea0ad3d..b9a84fb 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -112,10 +112,14 @@ extern UINT8 FileExplorerVfrBin[]; /// #define MAX_CHAR 480 #define FILE_OPTION_OFFSET 0x8000 #define FILE_OPTION_MASK 0x7FFF #define QUESTION_ID_UPDATE_STEP 200 +#define MAX_FILE_NAME_LEN 20 +#define MAX_FOLDER_NAME_LEN 20 +#define NEW_FILE_QUESTION_ID_BASE 0x5000; +#define NEW_FOLDER_QUESTION_ID_BASE 0x6000; /** This function processes the results of changes in configuration. When user select a interactive opcode, this callback will be triggered. Based on the Question(QuestionId) that triggers the callback, the corresponding diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni b/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni index 2e28c27..e16adb6 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni @@ -1,8 +1,8 @@ ///** @file // -// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> +// Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR> // 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 // http://opensource.org/licenses/bsd-license.php // @@ -27,5 +27,35 @@ #string STR_NULL_STRING #language en-US " " #language fr-FR " " #string STR_FILE_EXPLORER_TITLE #language en-US "File Explorer" #language fr-FR "File Explorer" +#string STR_NEW_FILE #language en-US "***NEW FILE***" + #language fr-FR "***NEW FILE***" +#string STR_NEW_FILE_HELP #language en-US "This menu used to create a new file in current directory, jump to next page to name the new file" + #language fr-FR "This menu used to create a new file in current directory, jump to next page to name the new file" +#string STR_ADD_NEW_FILE_TITLE #language en-US "Create a new file" + #language fr-FR "Create a new file" +#string STR_ADD_NEW_FOLDER_TITLE #language en-US "Create a new folder" + #language fr-FR "Create a new folder" +#string STR_NEW_FILE_NAME_PROMPT #language en-US "File Name" + #language fr-FR "File Name" +#string STR_NEW_FILE_NAME_HELP #language en-US "Please input a name for the new file" + #language fr-FR "Please input a name for the new file" +#string STR_CREATE_FILE_AND_EXIT #language en-US "Create File and Exit" + #language fr-FR "Create File and Exit" +#string STR_NO_CREATE_FILE_AND_EXIT #language en-US "Discard Create and Exit" + #language fr-FR "Discard Create and Exit" +#string STR_NEW_FOLDER #language en-US "***NEW FOLDER***" + #language fr-FR "***NEW FOLDER***" +#string STR_NEW_FOLDER_HELP #language en-US "This menu used to create a new folder in current directory, jump to next page to name the new folder" + #language fr-FR "This menu used to create a new folder in current directory, jump to next page to name the new folder" +#string STR_ADD_NEW_FOLDER_TITLE #language en-US "Create a new folder" + #language fr-FR "Create a new folder" +#string STR_NEW_FOLDER_NAME_PROMPT #language en-US "Folder Name" + #language fr-FR "Folder Name" +#string STR_NEW_FOLDER_NAME_HELP #language en-US "Please input a name for the new folder" + #language fr-FR "Please input a name for the new folder" +#string STR_CREATE_FOLDER_AND_EXIT #language en-US "Create Folder and Exit" + #language fr-FR "Create Folder and Exit" +#string STR_NO_CREATE_FOLDER_AND_EXIT #language en-US "Discard Create and Exit" + #language fr-FR "Discard Create and Exit" diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr b/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr index ef7c99c..b2bf94d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr @@ -1,10 +1,10 @@ ///** @file // // File Explorer Formset // -// Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> +// Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> // 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 // http://opensource.org/licenses/bsd-license.php // @@ -26,6 +26,60 @@ formset label FORM_FILE_EXPLORER_ID; label LABEL_END; endform; + form formid = FORM_ADD_NEW_FILE_ID, + title = STRING_TOKEN(STR_ADD_NEW_FILE_TITLE); + + string + prompt = STRING_TOKEN(STR_NEW_FILE_NAME_PROMPT), + help = STRING_TOKEN(STR_NEW_FILE_NAME_HELP), + flags = INTERACTIVE, + key = NEW_FILE_NAME_ID, + minsize = 2, + maxsize = 20, + endstring; + + subtitle text = STRING_TOKEN(STR_NULL_STRING); + + text + help = STRING_TOKEN(STR_CREATE_FILE_AND_EXIT), + text = STRING_TOKEN(STR_CREATE_FILE_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_CREATE_FILE_AND_EXIT; + + text + help = STRING_TOKEN(STR_NO_CREATE_FILE_AND_EXIT), + text = STRING_TOKEN(STR_NO_CREATE_FILE_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_NO_CREATE_FILE_AND_EXIT; + endform; + + form formid = FORM_ADD_NEW_FOLDER_ID, + title = STRING_TOKEN(STR_ADD_NEW_FOLDER_TITLE); + + string + prompt = STRING_TOKEN(STR_NEW_FOLDER_NAME_PROMPT), + help = STRING_TOKEN(STR_NEW_FOLDER_NAME_HELP), + flags = INTERACTIVE, + key = NEW_FOLDER_NAME_ID, + minsize = 2, + maxsize = 20, + endstring; + + subtitle text = STRING_TOKEN(STR_NULL_STRING); + + text + help = STRING_TOKEN(STR_CREATE_FOLDER_AND_EXIT), + text = STRING_TOKEN(STR_CREATE_FOLDER_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_CREATE_FOLDER_AND_EXIT; + + text + help = STRING_TOKEN(STR_NO_CREATE_FOLDER_AND_EXIT), + text = STRING_TOKEN(STR_NO_CREATE_FOLDER_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT; + endform; + endformset; \ No newline at end of file diff --git a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h index d0a43a9..a243e9f 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h +++ b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h @@ -1,9 +1,9 @@ /** @file Formset guids, form id and VarStore data structure for File explorer library. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -21,9 +21,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. { \ 0xfe561596, 0xe6bf, 0x41a6, {0x83, 0x76, 0xc7, 0x2b, 0x71, 0x98, 0x74, 0xd0} \ } #define FORM_FILE_EXPLORER_ID 0x1000 +#define FORM_ADD_NEW_FILE_ID 0x2000 +#define NEW_FILE_NAME_ID 0x2001 +#define KEY_VALUE_CREATE_FILE_AND_EXIT 0x2002 +#define KEY_VALUE_NO_CREATE_FILE_AND_EXIT 0x2003 +#define FORM_ADD_NEW_FOLDER_ID 0x3000 +#define NEW_FOLDER_NAME_ID 0x3001 +#define KEY_VALUE_CREATE_FOLDER_AND_EXIT 0x3002 +#define KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT 0x3003 + #define LABEL_END 0xffff #endif -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder 2017-01-16 5:57 ` [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder Dandan Bi @ 2017-01-18 2:50 ` Dong, Eric 0 siblings, 0 replies; 6+ messages in thread From: Dong, Eric @ 2017-01-18 2:50 UTC (permalink / raw) To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Yao, Jiewen Reviewed-by: Eric Dong <eric.dong@intel.com> -----Original Message----- From: Bi, Dandan Sent: Monday, January 16, 2017 1:57 PM To: edk2-devel@lists.01.org Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> Subject: [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder https://bugzilla.tianocore.org/show_bug.cgi?id=324 Enhance the FileExplorerlib so that user can create a new file/folder through the UI page. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/FileExplorerLib/FileExplorer.c | 170 ++++++++++++++++++++- .../Library/FileExplorerLib/FileExplorer.h | 4 + .../Library/FileExplorerLib/FileExplorerString.uni | 32 +++- .../Library/FileExplorerLib/FileExplorerVfr.vfr | 56 ++++++- MdeModulePkg/Library/FileExplorerLib/FormGuid.h | 11 +- 5 files changed, 267 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 315868a..5eedad7 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -71,10 +71,28 @@ HII_VENDOR_DEVICE_PATH FeHiiVendorDevicePath = { VOID *mLibStartOpCodeHandle = NULL; VOID *mLibEndOpCodeHandle = NULL; EFI_IFR_GUID_LABEL *mLibStartLabel = NULL; EFI_IFR_GUID_LABEL *mLibEndLabel = NULL; UINT16 mQuestionIdUpdate; +CHAR16 mNewFileName[MAX_FILE_NAME_LEN]; +CHAR16 mNewFolderName[MAX_FOLDER_NAME_LEN]; +UINTN mNewFileQuestionId = NEW_FILE_QUESTION_ID_BASE; +UINTN mNewFolderQuestionId = NEW_FOLDER_QUESTION_ID_BASE; + +/** + Create a new file or folder in current directory. + + @param FileName Point to the fileNmae or folder. + @param CreateFile CreateFile== TRUE means create a new file. + CreateFile== FALSE means create a new Folder. + +**/ +EFI_STATUS +LibCreateNewFile ( + IN CHAR16 *FileName, + IN BOOLEAN CreateFile + ); /** This function allows a caller to extract the current configuration for one or more named elements from the target driver. @@ -173,13 +191,17 @@ LibCallback ( OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { EFI_STATUS Status; BOOLEAN NeedExit; + CHAR16 *NewFileName; + CHAR16 *NewFolderName; NeedExit = TRUE; - + NewFileName = NULL; + NewFolderName = NULL; + if (Action != EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_CHANGED) { // // Do nothing for other UEFI Action. Only do call back when data is changed. // return EFI_UNSUPPORTED; @@ -187,11 +209,59 @@ LibCallback ( if (Action == EFI_BROWSER_ACTION_CHANGED) { if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } - + + if (QuestionId == KEY_VALUE_CREATE_FILE_AND_EXIT) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + if (!IsZeroBuffer (mNewFileName, sizeof (mNewFileName))) { + Status = LibCreateNewFile (mNewFileName,TRUE); + ZeroMem (mNewFileName,sizeof (mNewFileName)); + } + } + + if (QuestionId == KEY_VALUE_NO_CREATE_FILE_AND_EXIT) { + ZeroMem (mNewFileName,sizeof (mNewFileName)); + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + + if (QuestionId == KEY_VALUE_CREATE_FOLDER_AND_EXIT) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + if (!IsZeroBuffer (mNewFolderName, sizeof (mNewFolderName))) { + Status = LibCreateNewFile (mNewFolderName, FALSE); + ZeroMem (mNewFolderName,sizeof (mNewFolderName)); + } + } + + if (QuestionId == KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT) { + ZeroMem (mNewFolderName,sizeof (mNewFolderName)); + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + + if (QuestionId == NEW_FILE_NAME_ID) { + NewFileName = HiiGetString (gFileExplorerPrivate.FeHiiHandle, Value->string, NULL); + if (NewFileName != NULL) { + StrCpyS (mNewFileName, MAX_FILE_NAME_LEN, NewFileName); + FreePool (NewFileName); + NewFileName = NULL; + } else { + return EFI_INVALID_PARAMETER; + } + } + + if (QuestionId == NEW_FOLDER_NAME_ID) { + NewFolderName = HiiGetString (gFileExplorerPrivate.FeHiiHandle, Value->string, NULL); + if (NewFolderName != NULL) { + StrCpyS (mNewFolderName, MAX_FOLDER_NAME_LEN, NewFolderName); + FreePool (NewFolderName); + NewFolderName = NULL; + } else { + return EFI_INVALID_PARAMETER; + } + } + if (QuestionId >= FILE_OPTION_OFFSET) { LibGetDevicePath(QuestionId); // // Process the extra action. @@ -206,12 +276,12 @@ LibCallback ( } } else if (Action == EFI_BROWSER_ACTION_CHANGING) { if (Value == NULL) { return EFI_INVALID_PARAMETER; } - if (QuestionId >= FILE_OPTION_OFFSET) { + LibGetDevicePath(QuestionId); Status = LibUpdateFileExplorer (QuestionId); if (EFI_ERROR (Status)) { return Status; } } @@ -984,10 +1054,76 @@ Done: return Status; } /** + Create a new file or folder in current directory. + + @param FileName Point to the fileNmae or folder name. + @param CreateFile CreateFile== TRUE means create a new file. + CreateFile== FALSE means create a new Folder. + +**/ +EFI_STATUS +LibCreateNewFile ( + IN CHAR16 *FileName, + IN BOOLEAN CreateFile + ) +{ + EFI_FILE_HANDLE FileHandle; + EFI_FILE_HANDLE NewHandle; + EFI_HANDLE DeviceHandle; + EFI_STATUS Status; + CHAR16 *ParentName; + CHAR16 *FullFileName; + + NewHandle = NULL; + FullFileName = NULL; + + LibGetFileHandleFromDevicePath(gFileExplorerPrivate.RetDevicePath, + &FileHandle, &ParentName, &DeviceHandle); FullFileName = + LibAppendFileName (ParentName, FileName); if (FullFileName == NULL) { + return EFI_OUT_OF_RESOURCES; + } + if (CreateFile) { + Status = FileHandle->Open( + FileHandle, + &NewHandle, + FullFileName, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE, + 0 + ); + if (EFI_ERROR (Status)) { + FileHandle->Close (FileHandle); + return Status; + } + } else { + Status = FileHandle->Open( + FileHandle, + &NewHandle, + FullFileName, + EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE| EFI_FILE_MODE_CREATE, + EFI_FILE_DIRECTORY + ); + if (EFI_ERROR (Status)) { + FileHandle->Close (FileHandle); + return Status; + } + } + + FileHandle->Close (FileHandle); + + // + // Return the DevicePath of the new created file or folder. + // + gFileExplorerPrivate.RetDevicePath = FileDevicePath (DeviceHandle, + FullFileName); + + return EFI_SUCCESS; + +} + +/** Find files under current directory. All files and sub-directories in current directory will be stored in DirectoryMenu for future use. @@ -1175,23 +1311,51 @@ LibUpdateFileExplorePage ( { UINTN Index; MENU_ENTRY *NewMenuEntry; FILE_CONTEXT *NewFileContext; MENU_OPTION *MenuOption; + BOOLEAN CreateNewFile; NewMenuEntry = NULL; NewFileContext = NULL; + CreateNewFile = FALSE; LibRefreshUpdateData (); MenuOption = gFileExplorerPrivate.FsOptionMenu; mQuestionIdUpdate += QUESTION_ID_UPDATE_STEP; for (Index = 0; Index < MenuOption->MenuNumber; Index++) { NewMenuEntry = LibGetMenuEntry (MenuOption, Index); NewFileContext = (FILE_CONTEXT *) NewMenuEntry->VariableContext; + if (!NewFileContext->IsRoot && !CreateNewFile) { + HiiCreateGotoOpCode ( + mLibStartOpCodeHandle, + FORM_ADD_NEW_FILE_ID, + STRING_TOKEN (STR_NEW_FILE), + STRING_TOKEN (STR_NEW_FILE_HELP), + EFI_IFR_FLAG_CALLBACK, + (UINT16) (mNewFileQuestionId++) + ); + HiiCreateGotoOpCode ( + mLibStartOpCodeHandle, + FORM_ADD_NEW_FOLDER_ID, + STRING_TOKEN (STR_NEW_FOLDER), + STRING_TOKEN (STR_NEW_FOLDER_HELP), + EFI_IFR_FLAG_CALLBACK, + (UINT16) (mNewFolderQuestionId++) + ); + HiiCreateTextOpCode( + mLibStartOpCodeHandle, + STRING_TOKEN (STR_NULL_STRING), + STRING_TOKEN (STR_NULL_STRING), + 0 + ); + CreateNewFile = TRUE; + } + if (!NewFileContext->IsDir) { // // Create Text opcode for directory, also create Text opcode for file in FileExplorerStateBootFromFile. // HiiCreateActionOpCode ( diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index ea0ad3d..b9a84fb 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -112,10 +112,14 @@ extern UINT8 FileExplorerVfrBin[]; /// #define MAX_CHAR 480 #define FILE_OPTION_OFFSET 0x8000 #define FILE_OPTION_MASK 0x7FFF #define QUESTION_ID_UPDATE_STEP 200 +#define MAX_FILE_NAME_LEN 20 +#define MAX_FOLDER_NAME_LEN 20 +#define NEW_FILE_QUESTION_ID_BASE 0x5000; +#define NEW_FOLDER_QUESTION_ID_BASE 0x6000; /** This function processes the results of changes in configuration. When user select a interactive opcode, this callback will be triggered. Based on the Question(QuestionId) that triggers the callback, the corresponding diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni b/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni index 2e28c27..e16adb6 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerString.uni @@ -1,8 +1,8 @@ ///** @file // -// Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR> +// Copyright (c) 2007 - 2017, Intel Corporation. All rights +reserved.<BR> // 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 // http://opensource.org/licenses/bsd-license.php // @@ -27,5 +27,35 @@ #string STR_NULL_STRING #language en-US " " #language fr-FR " " #string STR_FILE_EXPLORER_TITLE #language en-US "File Explorer" #language fr-FR "File Explorer" +#string STR_NEW_FILE #language en-US "***NEW FILE***" + #language fr-FR "***NEW FILE***" +#string STR_NEW_FILE_HELP #language en-US "This menu used to create a new file in current directory, jump to next page to name the new file" + #language fr-FR "This menu used to create a new file in current directory, jump to next page to name the new file" +#string STR_ADD_NEW_FILE_TITLE #language en-US "Create a new file" + #language fr-FR "Create a new file" +#string STR_ADD_NEW_FOLDER_TITLE #language en-US "Create a new folder" + #language fr-FR "Create a new folder" +#string STR_NEW_FILE_NAME_PROMPT #language en-US "File Name" + #language fr-FR "File Name" +#string STR_NEW_FILE_NAME_HELP #language en-US "Please input a name for the new file" + #language fr-FR "Please input a name for the new file" +#string STR_CREATE_FILE_AND_EXIT #language en-US "Create File and Exit" + #language fr-FR "Create File and Exit" +#string STR_NO_CREATE_FILE_AND_EXIT #language en-US "Discard Create and Exit" + #language fr-FR "Discard Create and Exit" +#string STR_NEW_FOLDER #language en-US "***NEW FOLDER***" + #language fr-FR "***NEW FOLDER***" +#string STR_NEW_FOLDER_HELP #language en-US "This menu used to create a new folder in current directory, jump to next page to name the new folder" + #language fr-FR "This menu used to create a new folder in current directory, jump to next page to name the new folder" +#string STR_ADD_NEW_FOLDER_TITLE #language en-US "Create a new folder" + #language fr-FR "Create a new folder" +#string STR_NEW_FOLDER_NAME_PROMPT #language en-US "Folder Name" + #language fr-FR "Folder Name" +#string STR_NEW_FOLDER_NAME_HELP #language en-US "Please input a name for the new folder" + #language fr-FR "Please input a name for the new folder" +#string STR_CREATE_FOLDER_AND_EXIT #language en-US "Create Folder and Exit" + #language fr-FR "Create Folder and Exit" +#string STR_NO_CREATE_FOLDER_AND_EXIT #language en-US "Discard Create and Exit" + #language fr-FR "Discard Create and Exit" diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr b/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr index ef7c99c..b2bf94d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerVfr.vfr @@ -1,10 +1,10 @@ ///** @file // // File Explorer Formset // -// Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR> +// Copyright (c) 2004 - 2017, Intel Corporation. All rights +reserved.<BR> // 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 // http://opensource.org/licenses/bsd-license.php // @@ -26,6 +26,60 @@ formset label FORM_FILE_EXPLORER_ID; label LABEL_END; endform; + form formid = FORM_ADD_NEW_FILE_ID, + title = STRING_TOKEN(STR_ADD_NEW_FILE_TITLE); + + string + prompt = STRING_TOKEN(STR_NEW_FILE_NAME_PROMPT), + help = STRING_TOKEN(STR_NEW_FILE_NAME_HELP), + flags = INTERACTIVE, + key = NEW_FILE_NAME_ID, + minsize = 2, + maxsize = 20, + endstring; + + subtitle text = STRING_TOKEN(STR_NULL_STRING); + + text + help = STRING_TOKEN(STR_CREATE_FILE_AND_EXIT), + text = STRING_TOKEN(STR_CREATE_FILE_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_CREATE_FILE_AND_EXIT; + + text + help = STRING_TOKEN(STR_NO_CREATE_FILE_AND_EXIT), + text = STRING_TOKEN(STR_NO_CREATE_FILE_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_NO_CREATE_FILE_AND_EXIT; + endform; + + form formid = FORM_ADD_NEW_FOLDER_ID, + title = STRING_TOKEN(STR_ADD_NEW_FOLDER_TITLE); + + string + prompt = STRING_TOKEN(STR_NEW_FOLDER_NAME_PROMPT), + help = STRING_TOKEN(STR_NEW_FOLDER_NAME_HELP), + flags = INTERACTIVE, + key = NEW_FOLDER_NAME_ID, + minsize = 2, + maxsize = 20, + endstring; + + subtitle text = STRING_TOKEN(STR_NULL_STRING); + + text + help = STRING_TOKEN(STR_CREATE_FOLDER_AND_EXIT), + text = STRING_TOKEN(STR_CREATE_FOLDER_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_CREATE_FOLDER_AND_EXIT; + + text + help = STRING_TOKEN(STR_NO_CREATE_FOLDER_AND_EXIT), + text = STRING_TOKEN(STR_NO_CREATE_FOLDER_AND_EXIT), + flags = INTERACTIVE, + key = KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT; + endform; + endformset; \ No newline at end of file diff --git a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h index d0a43a9..a243e9f 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FormGuid.h +++ b/MdeModulePkg/Library/FileExplorerLib/FormGuid.h @@ -1,9 +1,9 @@ /** @file Formset guids, form id and VarStore data structure for File explorer library. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -21,9 +21,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. { \ 0xfe561596, 0xe6bf, 0x41a6, {0x83, 0x76, 0xc7, 0x2b, 0x71, 0x98, 0x74, 0xd0} \ } #define FORM_FILE_EXPLORER_ID 0x1000 +#define FORM_ADD_NEW_FILE_ID 0x2000 +#define NEW_FILE_NAME_ID 0x2001 +#define KEY_VALUE_CREATE_FILE_AND_EXIT 0x2002 +#define KEY_VALUE_NO_CREATE_FILE_AND_EXIT 0x2003 +#define FORM_ADD_NEW_FOLDER_ID 0x3000 +#define NEW_FOLDER_NAME_ID 0x3001 +#define KEY_VALUE_CREATE_FOLDER_AND_EXIT 0x3002 +#define KEY_VALUE_NO_CREATE_FOLDER_AND_EXIT 0x3003 + #define LABEL_END 0xffff #endif -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol 2017-01-16 5:57 [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dandan Bi 2017-01-16 5:57 ` [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form Dandan Bi 2017-01-16 5:57 ` [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder Dandan Bi @ 2017-01-18 2:50 ` Dong, Eric 2 siblings, 0 replies; 6+ messages in thread From: Dong, Eric @ 2017-01-18 2:50 UTC (permalink / raw) To: Bi, Dandan, edk2-devel@lists.01.org; +Cc: Gao, Liming, Yao, Jiewen Reviewed-by: Eric Dong <eric.dong@intel.com> -----Original Message----- From: Bi, Dandan Sent: Monday, January 16, 2017 1:57 PM To: edk2-devel@lists.01.org Cc: Dong, Eric <eric.dong@intel.com>; Gao, Liming <liming.gao@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> Subject: [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol https://bugzilla.tianocore.org/show_bug.cgi?id=323 FileExplorer no need to search load file protocol to show files. Now remove the codes. Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> --- .../Library/FileExplorerLib/FileExplorer.c | 56 +--------------------- .../Library/FileExplorerLib/FileExplorer.h | 3 +- .../Library/FileExplorerLib/FileExplorerLib.inf | 3 +- 3 files changed, 3 insertions(+), 59 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 41a22aa..9cd366d 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -1,9 +1,9 @@ /** @file File explorer related functions. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR> This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -697,23 +697,20 @@ EFI_STATUS LibFindFileSystem ( VOID ) { UINTN NoSimpleFsHandles; - UINTN NoLoadFileHandles; EFI_HANDLE *SimpleFsHandle; - EFI_HANDLE *LoadFileHandle; UINT16 *VolumeLabel; UINTN Index; EFI_STATUS Status; MENU_ENTRY *MenuEntry; FILE_CONTEXT *FileContext; UINTN OptionNumber; EFI_FILE_SYSTEM_VOLUME_LABEL *Info; NoSimpleFsHandles = 0; - NoLoadFileHandles = 0; OptionNumber = 0; // // Locate Handles that support Simple File System protocol // @@ -794,61 +791,10 @@ LibFindFileSystem ( if (NoSimpleFsHandles != 0) { FreePool (SimpleFsHandle); } - // - // Searching for handles that support Load File protocol - // - Status = gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiLoadFileProtocolGuid, - NULL, - &NoLoadFileHandles, - &LoadFileHandle - ); - - if (!EFI_ERROR (Status)) { - for (Index = 0; Index < NoLoadFileHandles; Index++) { - MenuEntry = LibCreateMenuEntry (); - if (NULL == MenuEntry) { - FreePool (LoadFileHandle); - return EFI_OUT_OF_RESOURCES; - } - - FileContext = (FILE_CONTEXT *) MenuEntry->VariableContext; - FileContext->DeviceHandle = LoadFileHandle[Index]; - FileContext->IsRoot = TRUE; - - FileContext->DevicePath = DevicePathFromHandle (FileContext->DeviceHandle); - FileContext->FileName = LibDevicePathToStr (FileContext->DevicePath); - - MenuEntry->HelpString = LibDevicePathToStr (FileContext->DevicePath); - MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR); - ASSERT (MenuEntry->DisplayString != NULL); - UnicodeSPrint ( - MenuEntry->DisplayString, - MAX_CHAR, - L"Load File [%s]", - MenuEntry->HelpString - ); - MenuEntry->DisplayStringToken = HiiSetString ( - gFileExplorerPrivate.FeHiiHandle, - 0, - MenuEntry->DisplayString, - NULL - ); - - OptionNumber++; - InsertTailList (&gFileExplorerPrivate.FsOptionMenu->Head, &MenuEntry->Link); - } - } - - if (NoLoadFileHandles != 0) { - FreePool (LoadFileHandle); - } - gFileExplorerPrivate.FsOptionMenu->MenuNumber = OptionNumber; return EFI_SUCCESS; } diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h index fab2052..4b5f601 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.h @@ -1,9 +1,9 @@ /** @file File explorer lib. -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR> +Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR> 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 http://opensource.org/licenses/bsd-license.php @@ -21,11 +21,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/HiiConfigAccess.h> #include <Protocol/DevicePath.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/DevicePathToText.h> -#include <Protocol/LoadFile.h> #include <Protocol/FormBrowser2.h> #include <Library/DebugLib.h> #include <Library/BaseMemoryLib.h> #include <Library/UefiBootServicesTableLib.h> diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf index 8b4383b..c292aa2 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf @@ -1,9 +1,9 @@ ## @file # library defines a set of interfaces for how to do file explorer. # -# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2011 - 2017, Intel Corporation. All rights +reserved.<BR> # This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php. # @@ -53,11 +53,10 @@ [Guids] gEfiFileSystemVolumeLabelInfoIdGuid ## CONSUMES ## GUID (Indicate the information type is volume) gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode) [Protocols] gEfiSimpleFileSystemProtocolGuid ## CONSUMES - gEfiLoadFileProtocolGuid ## CONSUMES gEfiHiiConfigAccessProtocolGuid ## CONSUMES gEfiFormBrowser2ProtocolGuid ## CONSUMES gEfiDevicePathToTextProtocolGuid ## CONSUMES [Depex.common.DXE_DRIVER] -- 1.9.5.msysgit.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-01-18 2:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-16 5:57 [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dandan Bi 2017-01-16 5:57 ` [patch 2/3] MdeModulePkg/FileExplorer: Update QuesrionId when Updating FileExplore form Dandan Bi 2017-01-18 2:50 ` Dong, Eric 2017-01-16 5:57 ` [patch 3/3] MdeModulePkg/FileExplorer: Enable functionality of creating new file/folder Dandan Bi 2017-01-18 2:50 ` Dong, Eric 2017-01-18 2:50 ` [patch 1/3] MdeModulePkg/FileExplorer: Remove the codes of searching load file protocol Dong, Eric
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox