flip_wifi.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "flip_wifi.h"
  2. FlipWiFiApp* app_instance = NULL;
  3. // Function to free the resources used by FlipWiFiApp
  4. void flip_wifi_app_free(FlipWiFiApp* app) {
  5. if(!app) {
  6. FURI_LOG_E(TAG, "FlipWiFiApp is NULL");
  7. return;
  8. }
  9. // Free View(s)
  10. if(app->view_wifi_scan) {
  11. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewWiFiScan);
  12. view_free(app->view_wifi_scan);
  13. }
  14. if(app->view_wifi_saved) {
  15. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewWiFiSaved);
  16. view_free(app->view_wifi_saved);
  17. }
  18. // Free Submenu(s)
  19. if(app->submenu_main) {
  20. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuMain);
  21. submenu_free(app->submenu_main);
  22. }
  23. if(app->submenu_wifi_scan) {
  24. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuScan);
  25. submenu_free(app->submenu_wifi_scan);
  26. }
  27. if(app->submenu_wifi_saved) {
  28. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuSaved);
  29. submenu_free(app->submenu_wifi_saved);
  30. }
  31. // Free Widget(s)
  32. if(app->widget_info) {
  33. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewAbout);
  34. widget_free(app->widget_info);
  35. }
  36. // Free Text Input(s)
  37. if(app->uart_text_input_password_scan) {
  38. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputScan);
  39. text_input_free(app->uart_text_input_password_scan);
  40. }
  41. if(app->uart_text_input_password_saved) {
  42. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSaved);
  43. text_input_free(app->uart_text_input_password_saved);
  44. }
  45. if(app->uart_text_input_add_ssid) {
  46. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddSSID);
  47. text_input_free(app->uart_text_input_add_ssid);
  48. }
  49. if(app->uart_text_input_add_password) {
  50. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddPassword);
  51. text_input_free(app->uart_text_input_add_password);
  52. }
  53. // free playlist
  54. for(size_t i = 0; i < app->wifi_playlist.count; i++) {
  55. if(app->wifi_playlist.ssids[i]) free(app->wifi_playlist.ssids[i]);
  56. if(app->wifi_playlist.passwords[i]) free(app->wifi_playlist.passwords[i]);
  57. }
  58. // free popup
  59. if(app->popup) {
  60. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewPopup);
  61. popup_free(app->popup);
  62. }
  63. // deinitalize flipper http
  64. flipper_http_deinit();
  65. // free the view dispatcher
  66. if(app->view_dispatcher) view_dispatcher_free(app->view_dispatcher);
  67. // close the gui
  68. furi_record_close(RECORD_GUI);
  69. // free the app
  70. if(app) free(app);
  71. }