flip_library.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "flip_library.h"
  2. FlipLibraryApp* app_instance = NULL;
  3. void flip_library_loader_free_model(View* view);
  4. // Function to free the resources used by FlipLibraryApp
  5. void flip_library_app_free(FlipLibraryApp* app) {
  6. if(!app) {
  7. FURI_LOG_E(TAG, "FlipLibraryApp is NULL");
  8. return;
  9. }
  10. // Free View(s)
  11. if(app->view_loader) {
  12. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewLoader);
  13. flip_library_loader_free_model(app->view_loader);
  14. view_free(app->view_loader);
  15. }
  16. // Free Submenu(s)
  17. if(app->submenu_main) {
  18. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewSubmenuMain);
  19. submenu_free(app->submenu_main);
  20. }
  21. if(app->submenu_random_facts) {
  22. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewRandomFacts);
  23. submenu_free(app->submenu_random_facts);
  24. }
  25. // Free Widget(s)
  26. if(app->widget_about) {
  27. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewAbout);
  28. widget_free(app->widget_about);
  29. }
  30. if(app->widget_result) {
  31. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewWidgetResult);
  32. widget_free(app->widget_result);
  33. }
  34. // Free Variable Item List(s)
  35. if(app->variable_item_list_wifi) {
  36. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewSettings);
  37. variable_item_list_free(app->variable_item_list_wifi);
  38. }
  39. // Free Text Input(s)
  40. if(app->uart_text_input_ssid) {
  41. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewTextInputSSID);
  42. text_input_free(app->uart_text_input_ssid);
  43. }
  44. if(app->uart_text_input_password) {
  45. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewTextInputPassword);
  46. text_input_free(app->uart_text_input_password);
  47. }
  48. if(app->uart_text_input_query) {
  49. view_dispatcher_remove_view(app->view_dispatcher, FlipLibraryViewTextInputQuery);
  50. text_input_free(app->uart_text_input_query);
  51. }
  52. // deinitalize flipper http
  53. flipper_http_deinit();
  54. // free the view dispatcher
  55. if(app->view_dispatcher) {
  56. view_dispatcher_free(app->view_dispatcher);
  57. }
  58. // close the gui
  59. furi_record_close(RECORD_GUI);
  60. if(app_instance) {
  61. // free the app instance
  62. free(app_instance);
  63. app_instance = NULL;
  64. }
  65. // free the app
  66. free(app);
  67. }