web_crawler.h 4.4 KB

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