24
24
25
25
static void render_callback (Canvas * const canvas , void * ctx ) {
26
26
PluginState * plugin_state = acquire_mutex ((ValueMutex * )ctx , 25 );
27
- if (plugin_state != NULL && !plugin_state -> changing_scene ) {
27
+ if (plugin_state != NULL && !plugin_state -> changing_scene ) {
28
28
totp_scene_director_render (canvas , plugin_state );
29
29
}
30
30
@@ -49,29 +49,43 @@ static bool totp_plugin_state_init(PluginState* const plugin_state) {
49
49
50
50
totp_scene_director_init_scenes (plugin_state );
51
51
52
- if (plugin_state -> crypto_verify_data == NULL ) {
52
+ if (plugin_state -> crypto_verify_data == NULL ) {
53
53
DialogMessage * message = dialog_message_alloc ();
54
54
dialog_message_set_buttons (message , "No" , NULL , "Yes" );
55
- dialog_message_set_text (message , "Would you like to setup PIN?" , SCREEN_WIDTH_CENTER , SCREEN_HEIGHT_CENTER , AlignCenter , AlignCenter );
55
+ dialog_message_set_text (
56
+ message ,
57
+ "Would you like to setup PIN?" ,
58
+ SCREEN_WIDTH_CENTER ,
59
+ SCREEN_HEIGHT_CENTER ,
60
+ AlignCenter ,
61
+ AlignCenter );
56
62
DialogMessageButton dialog_result = dialog_message_show (plugin_state -> dialogs , message );
57
63
dialog_message_free (message );
58
- if (dialog_result == DialogMessageButtonRight ) {
64
+ if (dialog_result == DialogMessageButtonRight ) {
59
65
totp_scene_director_activate_scene (plugin_state , TotpSceneAuthentication , NULL );
60
66
} else {
61
67
totp_crypto_seed_iv (plugin_state , NULL , 0 );
62
68
totp_scene_director_activate_scene (plugin_state , TotpSceneGenerateToken , NULL );
63
69
}
64
- } else if (plugin_state -> pin_set ) {
70
+ } else if (plugin_state -> pin_set ) {
65
71
totp_scene_director_activate_scene (plugin_state , TotpSceneAuthentication , NULL );
66
72
} else {
67
73
totp_crypto_seed_iv (plugin_state , NULL , 0 );
68
- if (totp_crypto_verify_key (plugin_state )) {
74
+ if (totp_crypto_verify_key (plugin_state )) {
69
75
totp_scene_director_activate_scene (plugin_state , TotpSceneGenerateToken , NULL );
70
76
} else {
71
- FURI_LOG_E (LOGGING_TAG , "Digital signature verification failed. Looks like conf file was created on another flipper and can't be used on any other" );
77
+ FURI_LOG_E (
78
+ LOGGING_TAG ,
79
+ "Digital signature verification failed. Looks like conf file was created on another flipper and can't be used on any other" );
72
80
DialogMessage * message = dialog_message_alloc ();
73
81
dialog_message_set_buttons (message , "Exit" , NULL , NULL );
74
- dialog_message_set_text (message , "Digital signature verification failed" , SCREEN_WIDTH_CENTER , SCREEN_HEIGHT_CENTER , AlignCenter , AlignCenter );
82
+ dialog_message_set_text (
83
+ message ,
84
+ "Digital signature verification failed" ,
85
+ SCREEN_WIDTH_CENTER ,
86
+ SCREEN_HEIGHT_CENTER ,
87
+ AlignCenter ,
88
+ AlignCenter );
75
89
dialog_message_show (plugin_state -> dialogs , message );
76
90
dialog_message_free (message );
77
91
return false;
@@ -94,15 +108,15 @@ static void totp_plugin_state_free(PluginState* plugin_state) {
94
108
95
109
ListNode * node = plugin_state -> tokens_list ;
96
110
ListNode * tmp ;
97
- while (node != NULL ) {
111
+ while (node != NULL ) {
98
112
tmp = node -> next ;
99
113
TokenInfo * tokenInfo = node -> data ;
100
114
token_info_free (tokenInfo );
101
115
free (node );
102
116
node = tmp ;
103
117
}
104
118
105
- if (plugin_state -> crypto_verify_data != NULL ) {
119
+ if (plugin_state -> crypto_verify_data != NULL ) {
106
120
free (plugin_state -> crypto_verify_data );
107
121
}
108
122
free (plugin_state );
@@ -113,7 +127,7 @@ int32_t totp_app() {
113
127
PluginState * plugin_state = malloc (sizeof (PluginState ));
114
128
furi_check (plugin_state != NULL );
115
129
116
- if (!totp_plugin_state_init (plugin_state )) {
130
+ if (!totp_plugin_state_init (plugin_state )) {
117
131
FURI_LOG_E (LOGGING_TAG , "App state initialization failed\r\n" );
118
132
totp_plugin_state_free (plugin_state );
119
133
return 254 ;
@@ -138,18 +152,20 @@ int32_t totp_app() {
138
152
bool processing = true;
139
153
uint32_t last_user_interaction_time = furi_get_tick ();
140
154
while (processing ) {
141
- if (plugin_state -> changing_scene ) continue ;
155
+ if (plugin_state -> changing_scene ) continue ;
142
156
FuriStatus event_status = furi_message_queue_get (event_queue , & event , 100 );
143
157
144
158
PluginState * plugin_state_m = acquire_mutex_block (& state_mutex );
145
159
146
160
if (event_status == FuriStatusOk ) {
147
- if (event .type == EventTypeKey ) {
161
+ if (event .type == EventTypeKey ) {
148
162
last_user_interaction_time = furi_get_tick ();
149
163
}
150
164
151
165
processing = totp_scene_director_handle_event (& event , plugin_state_m );
152
- } else if (plugin_state_m -> pin_set && plugin_state_m -> current_scene != TotpSceneAuthentication && furi_get_tick () - last_user_interaction_time > IDLE_TIMEOUT ) {
166
+ } else if (
167
+ plugin_state_m -> pin_set && plugin_state_m -> current_scene != TotpSceneAuthentication &&
168
+ furi_get_tick () - last_user_interaction_time > IDLE_TIMEOUT ) {
153
169
totp_scene_director_activate_scene (plugin_state_m , TotpSceneAuthentication , NULL );
154
170
}
155
171
0 commit comments