2022-02-02 14:27:33 +00:00
|
|
|
#include "../u2f_app_i.h"
|
|
|
|
|
|
|
|
static void u2f_scene_error_event_callback(GuiButtonType result, InputType type, void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
U2fApp* app = context;
|
|
|
|
|
|
|
|
if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
|
|
|
view_dispatcher_send_custom_event(app->view_dispatcher, U2fCustomEventErrorBack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void u2f_scene_error_on_enter(void* context) {
|
|
|
|
U2fApp* app = context;
|
|
|
|
|
2022-03-24 15:45:03 +00:00
|
|
|
if(app->error == U2fAppErrorNoFiles) {
|
|
|
|
widget_add_icon_element(app->widget, 0, 0, &I_SDQuestion_35x43);
|
|
|
|
widget_add_string_multiline_element(
|
|
|
|
app->widget,
|
|
|
|
81,
|
|
|
|
4,
|
|
|
|
AlignCenter,
|
|
|
|
AlignTop,
|
|
|
|
FontSecondary,
|
|
|
|
"No SD card or\napp data found.\nThis app will not\nwork without\nrequired files.");
|
2022-07-25 12:11:34 +00:00
|
|
|
widget_add_button_element(
|
|
|
|
app->widget, GuiButtonTypeLeft, "Back", u2f_scene_error_event_callback, app);
|
2022-03-24 15:45:03 +00:00
|
|
|
} else if(app->error == U2fAppErrorCloseRpc) {
|
2022-07-25 12:11:34 +00:00
|
|
|
widget_add_icon_element(app->widget, 78, 0, &I_ActiveConnection_50x64);
|
|
|
|
widget_add_string_multiline_element(
|
2024-03-25 07:00:35 +00:00
|
|
|
app->widget, 3, 2, AlignLeft, AlignTop, FontPrimary, "Connection\nIs Active!");
|
2022-03-24 15:45:03 +00:00
|
|
|
widget_add_string_multiline_element(
|
|
|
|
app->widget,
|
2022-07-25 12:11:34 +00:00
|
|
|
3,
|
|
|
|
30,
|
|
|
|
AlignLeft,
|
2022-03-24 15:45:03 +00:00
|
|
|
AlignTop,
|
|
|
|
FontSecondary,
|
2022-07-25 12:11:34 +00:00
|
|
|
"Disconnect from\nPC or phone to\nuse this function.");
|
2022-03-24 15:45:03 +00:00
|
|
|
}
|
2022-02-02 14:27:33 +00:00
|
|
|
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, U2fAppViewError);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool u2f_scene_error_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
U2fApp* app = context;
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
if(event.event == U2fCustomEventErrorBack) {
|
|
|
|
view_dispatcher_stop(app->view_dispatcher);
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void u2f_scene_error_on_exit(void* context) {
|
|
|
|
U2fApp* app = context;
|
2022-02-02 19:59:28 +00:00
|
|
|
widget_reset(app->widget);
|
2022-02-02 14:27:33 +00:00
|
|
|
}
|