web_crawler.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // web_crawler_e.h
  2. #ifndef WEB_CRAWLER_E
  3. #define WEB_CRAWLER_E
  4. #include <easy_flipper/easy_flipper.h>
  5. #include <flipper_http/flipper_http.h>
  6. #include <jsmn/jsmn.h>
  7. #include "web_crawler_icons.h"
  8. #include <storage/storage.h>
  9. #define TAG "Web Crawler"
  10. extern char* http_method_names[];
  11. // Define the submenu items for our WebCrawler application
  12. typedef enum {
  13. WebCrawlerSubmenuIndexRun, // click to go to Run the GET request
  14. WebCrawlerSubmenuIndexAbout, // click to go to About screen
  15. WebCrawlerSubmenuIndexConfig, // click to go to Config submenu (Wifi, File)
  16. WebCrawlerSubmenuIndexRequest, // click to go to Request submenu (Set URL, HTTP Method, Headers)
  17. WebCrawlerSubmenuIndexWifi, // click to go to Wifi submenu (SSID, Password)
  18. WebCrawlerSubmenuIndexFile, // click to go to file submenu (Read, File Type, Rename, Delete)
  19. } WebCrawlerSubmenuIndex;
  20. typedef enum {
  21. WebCrawlerViewAbout, // About screen
  22. WebCrawlerViewSubmenuConfig, // Submenu Config view for App (Wifi, File)
  23. WebCrawlerViewVariableItemListRequest, // Submenu for URL (Set URL, HTTP Method, Headers)
  24. WebCrawlerViewVariableItemListWifi, // Wifi Configuration screen (Submenu for SSID, Password)
  25. WebCrawlerViewVariableItemListFile, // Submenu for File (Read, File Type, Rename, Delete)
  26. WebCrawlerViewSubmenuMain, // Submenu Main view for App (Run, About, Config)
  27. WebCrawlerViewTextInput, // Text input for Path
  28. WebCrawlerViewTextInputSSID, // Text input for SSID
  29. WebCrawlerViewTextInputPassword, // Text input for Password
  30. WebCrawlerViewFileRead, // File Read
  31. WebCrawlerViewTextInputFileType, // Text input for File Type
  32. WebCrawlerViewTextInputFileRename, // Text input for File Rename
  33. WebCrawlerViewTextInputHeaders, // Text input for Headers
  34. WebCrawlerViewTextInputPayload, // Text input for Payload
  35. WebCrawlerViewFileDelete, // File Delete
  36. //
  37. WebCrawlerViewWidgetResult, // The text box that displays the random fact
  38. WebCrawlerViewLoader, // The loader screen retrieves data from the internet
  39. } WebCrawlerViewIndex;
  40. // Define the application structure
  41. typedef struct {
  42. ViewDispatcher* view_dispatcher;
  43. View* view_main;
  44. View* view_run;
  45. View* view_loader;
  46. Submenu* submenu_main;
  47. Submenu* submenu_config;
  48. Widget* widget_about;
  49. Widget* widget_result; // The widget that displays the result
  50. TextInput* text_input_path;
  51. TextInput* text_input_ssid;
  52. TextInput* text_input_password;
  53. TextInput* text_input_file_type;
  54. TextInput* text_input_file_rename;
  55. //
  56. TextInput* text_input_headers;
  57. TextInput* text_input_payload;
  58. Widget* widget_file_read;
  59. Widget* widget_file_delete;
  60. VariableItemList* variable_item_list_wifi;
  61. VariableItemList* variable_item_list_file;
  62. VariableItemList* variable_item_list_request;
  63. VariableItem* path_item;
  64. VariableItem* ssid_item;
  65. VariableItem* password_item;
  66. VariableItem* file_type_item;
  67. VariableItem* file_rename_item;
  68. VariableItem* file_read_item;
  69. VariableItem* file_delete_item;
  70. //
  71. VariableItem* http_method_item;
  72. VariableItem* headers_item;
  73. VariableItem* payload_item;
  74. char* path;
  75. char* ssid;
  76. char* password;
  77. char* file_type;
  78. char* file_rename;
  79. char* http_method;
  80. char* headers;
  81. char* payload;
  82. char* temp_buffer_path;
  83. uint32_t temp_buffer_size_path;
  84. char* temp_buffer_ssid;
  85. uint32_t temp_buffer_size_ssid;
  86. char* temp_buffer_password;
  87. uint32_t temp_buffer_size_password;
  88. char* temp_buffer_file_type;
  89. uint32_t temp_buffer_size_file_type;
  90. char* temp_buffer_file_rename;
  91. uint32_t temp_buffer_size_file_rename;
  92. char* temp_buffer_http_method;
  93. uint32_t temp_buffer_size_http_method;
  94. char* temp_buffer_headers;
  95. uint32_t temp_buffer_size_headers;
  96. char* temp_buffer_payload;
  97. uint32_t temp_buffer_size_payload;
  98. } WebCrawlerApp;
  99. void free_buffers(WebCrawlerApp* app);
  100. void free_resources(WebCrawlerApp* app);
  101. void free_all(WebCrawlerApp* app, char* reason);
  102. /**
  103. * @brief Function to free the resources used by WebCrawlerApp.
  104. * @param app The WebCrawlerApp object to free.
  105. */
  106. void web_crawler_app_free(WebCrawlerApp* app);
  107. extern WebCrawlerApp* app_instance;
  108. #endif // WEB_CRAWLER_E