/** 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 actions is performed. It handles: 1) Process the axtra action or exit file explorer when user select one file . 2) update of file content if a dir is selected. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param Action Specifies the type of action taken by the browser. @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the type of data to expect. @param Type The type of value for the question. @param Value A pointer to the data being sent to the original exporting driver. @param ActionRequest On return, points to the action requested by the callback function. @retval EFI_SUCCESS The callback successfully handled the action. @retval other error Error occur when parse one directory. **/ EFI_STATUS EFIAPI LibCallback ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest ) { EFI_STATUS Status; BOOLEAN NeedExit; NeedExit = TRUE; 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; } if (Action == EFI_BROWSER_ACTION_CHANGED) { if ((Value == NULL) || (ActionRequest == NULL)) { return EFI_INVALID_PARAMETER; } if (QuestionId >= FILE_OPTION_OFFSET) { LibGetDevicePath(QuestionId); // // Process the extra action. // if (gFileExplorerPrivate.ChooseHandler != NULL) { NeedExit = gFileExplorerPrivate.ChooseHandler (gFileExplorerPrivate.RetDevicePath); } if (NeedExit) { *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; } } } else if (Action == EFI_BROWSER_ACTION_CHANGING) { if (Value == NULL) { return EFI_INVALID_PARAMETER; } if (QuestionId >= FILE_OPTION_OFFSET) { Status = LibUpdateFileExplorer (QuestionId); if (EFI_ERROR (Status)) { return Status; } } } return EFI_SUCCESS; }
/** 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 actions is performed. It handles: 1) Process the axtra action or exit file explorer when user select one file . 2) update of file content if a dir is selected. @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL. @param Action Specifies the type of action taken by the browser. @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the type of data to expect. @param Type The type of value for the question. @param Value A pointer to the data being sent to the original exporting driver. @param ActionRequest On return, points to the action requested by the callback function. @retval EFI_SUCCESS The callback successfully handled the action. @retval other error Error occur when parse one directory. **/ EFI_STATUS EFIAPI LibCallback ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, 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; } 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. // if (gFileExplorerPrivate.ChooseHandler != NULL) { NeedExit = gFileExplorerPrivate.ChooseHandler (gFileExplorerPrivate.RetDevicePath); } if (NeedExit) { *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; } } } 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; } } } return EFI_SUCCESS; }