2022-10-12 02:01:37 +00:00
|
|
|
#include "../types/common.h"
|
|
|
|
#include "scene_director.h"
|
2022-11-23 22:19:19 +00:00
|
|
|
#include "scenes/authenticate/totp_scene_authenticate.h"
|
|
|
|
#include "scenes/generate_token/totp_scene_generate_token.h"
|
|
|
|
#include "scenes/add_new_token/totp_scene_add_new_token.h"
|
|
|
|
#include "scenes/token_menu/totp_scene_token_menu.h"
|
|
|
|
#include "scenes/app_settings/totp_app_settings.h"
|
2022-10-12 02:01:37 +00:00
|
|
|
|
2022-10-13 14:00:20 +00:00
|
|
|
void totp_scene_director_activate_scene(
|
|
|
|
PluginState* const plugin_state,
|
|
|
|
Scene scene,
|
|
|
|
const void* context) {
|
2022-10-12 02:01:37 +00:00
|
|
|
totp_scene_director_deactivate_active_scene(plugin_state);
|
2022-10-13 14:00:20 +00:00
|
|
|
switch(scene) {
|
|
|
|
case TotpSceneGenerateToken:
|
|
|
|
totp_scene_generate_token_activate(plugin_state, context);
|
|
|
|
break;
|
|
|
|
case TotpSceneAuthentication:
|
|
|
|
totp_scene_authenticate_activate(plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAddNewToken:
|
|
|
|
totp_scene_add_new_token_activate(plugin_state, context);
|
|
|
|
break;
|
|
|
|
case TotpSceneTokenMenu:
|
|
|
|
totp_scene_token_menu_activate(plugin_state, context);
|
|
|
|
break;
|
|
|
|
case TotpSceneAppSettings:
|
|
|
|
totp_scene_app_settings_activate(plugin_state, context);
|
|
|
|
break;
|
2022-10-28 15:34:35 +00:00
|
|
|
case TotpSceneNone:
|
|
|
|
break;
|
2022-11-10 05:32:21 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-10-12 02:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
plugin_state->current_scene = scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
void totp_scene_director_deactivate_active_scene(PluginState* const plugin_state) {
|
2023-03-21 16:03:53 +00:00
|
|
|
Scene current_scene = plugin_state->current_scene;
|
|
|
|
plugin_state->current_scene = TotpSceneNone;
|
|
|
|
switch(current_scene) {
|
2022-10-13 14:00:20 +00:00
|
|
|
case TotpSceneGenerateToken:
|
|
|
|
totp_scene_generate_token_deactivate(plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAuthentication:
|
|
|
|
totp_scene_authenticate_deactivate(plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAddNewToken:
|
|
|
|
totp_scene_add_new_token_deactivate(plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneTokenMenu:
|
|
|
|
totp_scene_token_menu_deactivate(plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAppSettings:
|
|
|
|
totp_scene_app_settings_deactivate(plugin_state);
|
|
|
|
break;
|
2022-10-28 15:34:35 +00:00
|
|
|
case TotpSceneNone:
|
|
|
|
break;
|
2022-11-10 05:32:21 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-10-12 02:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void totp_scene_director_render(Canvas* const canvas, PluginState* const plugin_state) {
|
2022-10-13 14:00:20 +00:00
|
|
|
switch(plugin_state->current_scene) {
|
|
|
|
case TotpSceneGenerateToken:
|
|
|
|
totp_scene_generate_token_render(canvas, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAuthentication:
|
|
|
|
totp_scene_authenticate_render(canvas, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAddNewToken:
|
|
|
|
totp_scene_add_new_token_render(canvas, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneTokenMenu:
|
|
|
|
totp_scene_token_menu_render(canvas, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAppSettings:
|
|
|
|
totp_scene_app_settings_render(canvas, plugin_state);
|
|
|
|
break;
|
2022-10-28 15:34:35 +00:00
|
|
|
case TotpSceneNone:
|
|
|
|
break;
|
2022-11-10 05:32:21 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-10-12 02:01:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool totp_scene_director_handle_event(PluginEvent* const event, PluginState* const plugin_state) {
|
|
|
|
bool processing = true;
|
2022-10-13 14:00:20 +00:00
|
|
|
switch(plugin_state->current_scene) {
|
|
|
|
case TotpSceneGenerateToken:
|
|
|
|
processing = totp_scene_generate_token_handle_event(event, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAuthentication:
|
|
|
|
processing = totp_scene_authenticate_handle_event(event, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAddNewToken:
|
|
|
|
processing = totp_scene_add_new_token_handle_event(event, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneTokenMenu:
|
|
|
|
processing = totp_scene_token_menu_handle_event(event, plugin_state);
|
|
|
|
break;
|
|
|
|
case TotpSceneAppSettings:
|
|
|
|
processing = totp_scene_app_settings_handle_event(event, plugin_state);
|
|
|
|
break;
|
2022-10-28 15:34:35 +00:00
|
|
|
case TotpSceneNone:
|
|
|
|
break;
|
2022-11-10 05:32:21 +00:00
|
|
|
default:
|
|
|
|
break;
|
2022-10-12 02:01:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return processing;
|
|
|
|
}
|