flip_wifi.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. {
  6. if (!app)
  7. {
  8. FURI_LOG_E(TAG, "FlipWiFiApp is NULL");
  9. return;
  10. }
  11. // Free View(s)
  12. if (app->view_wifi_scan)
  13. {
  14. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewWiFiScan);
  15. view_free(app->view_wifi_scan);
  16. }
  17. if (app->view_wifi_saved)
  18. {
  19. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewWiFiSaved);
  20. view_free(app->view_wifi_saved);
  21. }
  22. // Free Submenu(s)
  23. if (app->submenu_main)
  24. {
  25. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuMain);
  26. submenu_free(app->submenu_main);
  27. }
  28. if (app->submenu_wifi_scan)
  29. {
  30. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuScan);
  31. submenu_free(app->submenu_wifi_scan);
  32. }
  33. if (app->submenu_wifi_saved)
  34. {
  35. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewSubmenuSaved);
  36. submenu_free(app->submenu_wifi_saved);
  37. }
  38. // Free Widget(s)
  39. if (app->widget_info)
  40. {
  41. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewAbout);
  42. widget_free(app->widget_info);
  43. }
  44. // Free Text Input(s)
  45. if (app->uart_text_input_password_scan)
  46. {
  47. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputScan);
  48. uart_text_input_free(app->uart_text_input_password_scan);
  49. }
  50. if (app->uart_text_input_password_saved)
  51. {
  52. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSaved);
  53. uart_text_input_free(app->uart_text_input_password_saved);
  54. }
  55. if (app->uart_text_input_add_ssid)
  56. {
  57. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddSSID);
  58. uart_text_input_free(app->uart_text_input_add_ssid);
  59. }
  60. if (app->uart_text_input_add_password)
  61. {
  62. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewTextInputSavedAddPassword);
  63. uart_text_input_free(app->uart_text_input_add_password);
  64. }
  65. // free playlist
  66. for (size_t i = 0; i < app->wifi_playlist.count; i++)
  67. {
  68. if (app->wifi_playlist.ssids[i])
  69. free(app->wifi_playlist.ssids[i]);
  70. if (app->wifi_playlist.passwords[i])
  71. free(app->wifi_playlist.passwords[i]);
  72. }
  73. // free popup
  74. if (app->popup)
  75. {
  76. view_dispatcher_remove_view(app->view_dispatcher, FlipWiFiViewPopup);
  77. popup_free(app->popup);
  78. }
  79. // deinitalize flipper http
  80. flipper_http_deinit();
  81. // free the view dispatcher
  82. if (app->view_dispatcher)
  83. view_dispatcher_free(app->view_dispatcher);
  84. // close the gui
  85. furi_record_close(RECORD_GUI);
  86. // free the app
  87. if (app)
  88. free(app);
  89. }