From 6bb92cd33065c112979d4eb04d2d19d174fc964a Mon Sep 17 00:00:00 2001 From: Alexis Grojean Date: Mon, 24 Jun 2024 12:00:38 +0200 Subject: [PATCH] Add setter functions in ux_sync lib for synchronous call return code and "end of flow" variables. --- lib_ux_sync/include/ux_sync.h | 4 +++- lib_ux_sync/src/ux_sync.c | 37 ++++++++++++++--------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lib_ux_sync/include/ux_sync.h b/lib_ux_sync/include/ux_sync.h index ef385c334..97710b76b 100644 --- a/lib_ux_sync/include/ux_sync.h +++ b/lib_ux_sync/include/ux_sync.h @@ -10,7 +10,9 @@ typedef enum { UX_SYNC_RET_ERROR } ux_sync_ret_t; -void ux_sync_genericContentActionCallback(int token, uint8_t index, int page); +void ux_sync_setReturnCode(ux_sync_ret_t ret); + +void ux_sync_setEnded(bool ended); ux_sync_ret_t ux_sync_homeAndSettings(const char *appName, const nbgl_icon_details_t *appIcon, diff --git a/lib_ux_sync/src/ux_sync.c b/lib_ux_sync/src/ux_sync.c index fc01605db..3f714c684 100644 --- a/lib_ux_sync/src/ux_sync.c +++ b/lib_ux_sync/src/ux_sync.c @@ -51,32 +51,25 @@ static ux_sync_ret_t ux_sync_wait(bool exitOnApdu) } /** - * @brief Callback to be used when filling the nbgl_contentActionCallback_t of nbgl_content_t - * structures used with the ux_sync_genericReview function. It will be called to confirm or reject a - * flow when the user touches a button (e.g. with nbgl_contentInfoButton_t) or long press button - * (e.g. with nbgl_contentInfoLongPress_t). The callback is triggered and is passed - * the token of the button that was touched. The button used to confirm the flow should - * have the token FIRST_USER_TOKEN. Other tokens will be considered as rejection of the flow. + * @brief Sets the return code of synchronous UX calls. Can be used by content action callbacks + * defined by application code. * - * @note This callback does not enable usage of more advanced generic content flows - * for instance when using nbgl_contentSwitchesList_t or nbgl_contentBarsList_t. + * @param ret return code to set. + */ +void ux_sync_setReturnCode(ux_sync_ret_t ret) +{ + g_ret = ret; +} + +/** + * @brief Sets the ended flag of synchronous UX calls. Can be used by content action callbacks + * defined by application code to end the UX flow. * - * @param token integer passed at content object initialization - * @param index when the object touched is a list of radio buttons, gives the index of the activated - * @param page index of the current page, can be used to restart the use_case directly at the right - * page button + * @param ended flag to set. */ -void ux_sync_genericContentActionCallback(int token, uint8_t index, int page) +void ux_sync_setEnded(bool ended) { - UNUSED(index); - UNUSED(page); - if (token == FIRST_USER_TOKEN) { - g_ret = UX_SYNC_RET_APPROVED; - } - else { - g_ret = UX_SYNC_RET_REJECTED; - } - g_ended = true; + g_ended = ended; } /**