web_crawler.h 4.3 KB

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