@@ -268,4 +268,139 @@ void app_info_ok_callback(void* context) {
268268void app_info_cancel_callback (void * context ) {
269269 // Use same callback as OK since both just return to previous view
270270 app_info_ok_callback (context );
271+ }
272+
273+ // Add these new callback declarations
274+ void wardrive_clear_confirmed_callback (void * context ) {
275+ FURI_LOG_D ("ClearWardrive" , "Confirmed callback started, context: %p" , context );
276+
277+ SettingsConfirmContext * ctx = context ;
278+ if (!ctx ) {
279+ FURI_LOG_E ("ClearWardrive" , "Null context" );
280+ return ;
281+ }
282+
283+ if (!ctx -> state ) {
284+ FURI_LOG_E ("ClearWardrive" , "Null state in context" );
285+ free (ctx );
286+ return ;
287+ }
288+
289+ AppState * app_state = ctx -> state ;
290+ uint32_t prev_view = app_state -> previous_view ;
291+
292+ FURI_LOG_D ("ClearWardrive" , "Previous view: %lu" , prev_view );
293+ clear_wardrive_files (ctx -> state );
294+
295+ // Reset callbacks
296+ confirmation_view_set_ok_callback (app_state -> confirmation_view , NULL , NULL );
297+ confirmation_view_set_cancel_callback (app_state -> confirmation_view , NULL , NULL );
298+
299+ free (ctx );
300+
301+ view_dispatcher_switch_to_view (app_state -> view_dispatcher , prev_view );
302+ app_state -> current_view = prev_view ;
303+ }
304+
305+ void wardrive_clear_cancelled_callback (void * context ) {
306+ // Similar to logs_clear_cancelled_callback
307+ SettingsConfirmContext * ctx = context ;
308+ if (!ctx || !ctx -> state ) {
309+ FURI_LOG_E ("ClearWardrive" , "Invalid context" );
310+ free (ctx );
311+ return ;
312+ }
313+
314+ AppState * app_state = ctx -> state ;
315+ uint32_t prev_view = app_state -> previous_view ;
316+
317+ confirmation_view_set_ok_callback (app_state -> confirmation_view , NULL , NULL );
318+ confirmation_view_set_cancel_callback (app_state -> confirmation_view , NULL , NULL );
319+
320+ free (ctx );
321+
322+ view_dispatcher_switch_to_view (app_state -> view_dispatcher , prev_view );
323+ app_state -> current_view = prev_view ;
324+ }
325+
326+ void pcap_clear_confirmed_callback (void * context ) {
327+ FURI_LOG_D ("ClearPCAP" , "Confirmed callback started, context: %p" , context );
328+
329+ SettingsConfirmContext * ctx = context ;
330+ if (!ctx ) {
331+ FURI_LOG_E ("ClearPCAP" , "Null context" );
332+ return ;
333+ }
334+
335+ if (!ctx -> state ) {
336+ FURI_LOG_E ("ClearPCAP" , "Null state in context" );
337+ free (ctx );
338+ return ;
339+ }
340+
341+ AppState * app_state = ctx -> state ;
342+ uint32_t prev_view = app_state -> previous_view ;
343+
344+ FURI_LOG_D ("ClearPCAP" , "Previous view: %lu" , prev_view );
345+ clear_pcap_files (ctx -> state );
346+
347+ confirmation_view_set_ok_callback (app_state -> confirmation_view , NULL , NULL );
348+ confirmation_view_set_cancel_callback (app_state -> confirmation_view , NULL , NULL );
349+
350+ free (ctx );
351+
352+ view_dispatcher_switch_to_view (app_state -> view_dispatcher , prev_view );
353+ app_state -> current_view = prev_view ;
354+ }
355+
356+ void pcap_clear_cancelled_callback (void * context ) {
357+ // Similar to logs_clear_cancelled_callback
358+ SettingsConfirmContext * ctx = context ;
359+ if (!ctx || !ctx -> state ) {
360+ FURI_LOG_E ("ClearPCAP" , "Invalid context" );
361+ free (ctx );
362+ return ;
363+ }
364+
365+ AppState * app_state = ctx -> state ;
366+ uint32_t prev_view = app_state -> previous_view ;
367+
368+ confirmation_view_set_ok_callback (app_state -> confirmation_view , NULL , NULL );
369+ confirmation_view_set_cancel_callback (app_state -> confirmation_view , NULL , NULL );
370+
371+ free (ctx );
372+
373+ view_dispatcher_switch_to_view (app_state -> view_dispatcher , prev_view );
374+ app_state -> current_view = prev_view ;
375+ }
376+
377+ // Add these variable item callbacks
378+ void on_clear_wardrive_changed (VariableItem * item ) {
379+ AppState * app = variable_item_get_context (item );
380+ uint8_t index = variable_item_get_current_value_index (item );
381+ variable_item_set_current_value_text (item , SETTING_VALUE_NAMES_ACTION [index ]);
382+
383+ if (index == 0 ) {
384+ show_confirmation_dialog_ex (
385+ app ,
386+ "Clear Wardrives" ,
387+ "Are you sure you want to clear\nall wardrive files?\nThis action cannot be undone." ,
388+ wardrive_clear_confirmed_callback ,
389+ wardrive_clear_cancelled_callback );
390+ }
391+ }
392+
393+ void on_clear_pcaps_changed (VariableItem * item ) {
394+ AppState * app = variable_item_get_context (item );
395+ uint8_t index = variable_item_get_current_value_index (item );
396+ variable_item_set_current_value_text (item , SETTING_VALUE_NAMES_ACTION [index ]);
397+
398+ if (index == 0 ) {
399+ show_confirmation_dialog_ex (
400+ app ,
401+ "Clear PCAPs" ,
402+ "Are you sure you want to clear\nall PCAP files?\nThis action cannot be undone." ,
403+ pcap_clear_confirmed_callback ,
404+ pcap_clear_cancelled_callback );
405+ }
271406}
0 commit comments