web_crawler_callback.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #ifndef WEB_CRAWLER_CALLBACK_H
  2. #define WEB_CRAWLER_CALLBACK_H
  3. #include "web_crawler.h"
  4. #include <flip_storage/web_crawler_storage.h>
  5. extern bool sent_http_request;
  6. extern bool get_success;
  7. extern bool already_success;
  8. void web_crawler_http_method_change(VariableItem* item);
  9. /**
  10. * @brief Navigation callback to handle exiting from other views to the submenu.
  11. * @param context The context - WebCrawlerApp object.
  12. * @return WebCrawlerViewSubmenu
  13. */
  14. uint32_t web_crawler_back_to_configure_callback(void* context);
  15. /**
  16. * @brief Navigation callback to handle returning to the Wifi Settings screen.
  17. * @param context The context - WebCrawlerApp object.
  18. * @return WebCrawlerViewSubmenu
  19. */
  20. uint32_t web_crawler_back_to_main_callback(void* context);
  21. uint32_t web_crawler_back_to_file_callback(void* context);
  22. uint32_t web_crawler_back_to_wifi_callback(void* context);
  23. uint32_t web_crawler_back_to_request_callback(void* context);
  24. /**
  25. * @brief Navigation callback to handle exiting the app from the main submenu.
  26. * @param context The context - unused
  27. * @return VIEW_NONE to exit the app
  28. */
  29. uint32_t web_crawler_exit_app_callback(void* context);
  30. /**
  31. * @brief Handle submenu item selection.
  32. * @param context The context - WebCrawlerApp object.
  33. * @param index The WebCrawlerSubmenuIndex item that was clicked.
  34. */
  35. void web_crawler_submenu_callback(void* context, uint32_t index);
  36. /**
  37. * @brief Configuration enter callback to handle different items.
  38. * @param context The context - WebCrawlerApp object.
  39. * @param index The index of the item that was clicked.
  40. */
  41. void web_crawler_wifi_enter_callback(void* context, uint32_t index);
  42. /**
  43. * @brief Configuration enter callback to handle different items.
  44. * @param context The context - WebCrawlerApp object.
  45. * @param index The index of the item that was clicked.
  46. */
  47. void web_crawler_file_enter_callback(void* context, uint32_t index);
  48. /**
  49. * @brief Configuration enter callback to handle different items.
  50. * @param context The context - WebCrawlerApp object.
  51. * @param index The index of the item that was clicked.
  52. */
  53. void web_crawler_request_enter_callback(void* context, uint32_t index);
  54. /**
  55. * @brief Callback for when the user finishes entering the URL.
  56. * @param context The context - WebCrawlerApp object.
  57. */
  58. void web_crawler_set_path_updated(void* context);
  59. /**
  60. * @brief Callback for when the user finishes entering the headers
  61. * @param context The context - WebCrawlerApp object.
  62. */
  63. void web_crawler_set_headers_updated(void* context);
  64. /**
  65. * @brief Callback for when the user finishes entering the payload.
  66. * @param context The context - WebCrawlerApp object.
  67. */
  68. void web_crawler_set_payload_updated(void* context);
  69. /**
  70. * @brief Callback for when the user finishes entering the SSID.
  71. * @param context The context - WebCrawlerApp object.
  72. */
  73. void web_crawler_set_ssid_updated(void* context);
  74. /**
  75. * @brief Callback for when the user finishes entering the Password.
  76. * @param context The context - WebCrawlerApp object.
  77. */
  78. void web_crawler_set_password_update(void* context);
  79. /**
  80. * @brief Callback for when the user finishes entering the File Type.
  81. * @param context The context - WebCrawlerApp object.
  82. */
  83. void web_crawler_set_file_type_update(void* context);
  84. /**
  85. * @brief Callback for when the user finishes entering the File Rename.
  86. * @param context The context - WebCrawlerApp object.
  87. */
  88. void web_crawler_set_file_rename_update(void* context);
  89. /**
  90. * @brief Handler for Path configuration item click.
  91. * @param context The context - WebCrawlerApp object.
  92. * @param index The index of the item that was clicked.
  93. */
  94. void web_crawler_setting_item_path_clicked(void* context, uint32_t index);
  95. /**
  96. * @brief Handler for headers configuration item click.
  97. * @param context The context - WebCrawlerApp object.
  98. * @param index The index of the item that was clicked.
  99. */
  100. void web_crawler_setting_item_headers_clicked(void* context, uint32_t index);
  101. /**
  102. * @brief Handler for payload configuration item click.
  103. * @param context The context - WebCrawlerApp object.
  104. * @param index The index of the item that was clicked.
  105. */
  106. void web_crawler_setting_item_payload_clicked(void* context, uint32_t index);
  107. /**
  108. * @brief Handler for SSID configuration item click.
  109. * @param context The context - WebCrawlerApp object.
  110. * @param index The index of the item that was clicked.
  111. */
  112. void web_crawler_setting_item_ssid_clicked(void* context, uint32_t index);
  113. /**
  114. * @brief Handler for Password configuration item click.
  115. * @param context The context - WebCrawlerApp object.
  116. * @param index The index of the item that was clicked.
  117. */
  118. void web_crawler_setting_item_password_clicked(void* context, uint32_t index);
  119. /**
  120. * @brief Handler for File Type configuration item click.
  121. * @param context The context - WebCrawlerApp object.
  122. * @param index The index of the item that was clicked.
  123. */
  124. void web_crawler_setting_item_file_type_clicked(void* context, uint32_t index);
  125. /**
  126. * @brief Handler for File Rename configuration item click.
  127. * @param context The context - WebCrawlerApp object.
  128. * @param index The index of the item that was clicked.
  129. */
  130. void web_crawler_setting_item_file_rename_clicked(void* context, uint32_t index);
  131. /**
  132. * @brief Handler for File Delete configuration item click.
  133. * @param context The context - WebCrawlerApp object.
  134. * @param index The index of the item that was clicked.
  135. */
  136. void web_crawler_setting_item_file_delete_clicked(void* context, uint32_t index);
  137. void web_crawler_setting_item_file_read_clicked(void* context, uint32_t index);
  138. // Add edits by Derek Jamison
  139. typedef enum DataState DataState;
  140. enum DataState {
  141. DataStateInitial,
  142. DataStateRequested,
  143. DataStateReceived,
  144. DataStateParsed,
  145. DataStateParseError,
  146. DataStateError,
  147. };
  148. typedef enum WebCrawlerCustomEvent WebCrawlerCustomEvent;
  149. enum WebCrawlerCustomEvent {
  150. WebCrawlerCustomEventProcess,
  151. };
  152. typedef struct DataLoaderModel DataLoaderModel;
  153. typedef bool (*DataLoaderFetch)(DataLoaderModel* model);
  154. typedef char* (*DataLoaderParser)(DataLoaderModel* model);
  155. struct DataLoaderModel {
  156. char* title;
  157. char* data_text;
  158. DataState data_state;
  159. DataLoaderFetch fetcher;
  160. DataLoaderParser parser;
  161. void* parser_context;
  162. size_t request_index;
  163. size_t request_count;
  164. ViewNavigationCallback back_callback;
  165. FuriTimer* timer;
  166. };
  167. void web_crawler_generic_switch_to_view(
  168. WebCrawlerApp* app,
  169. char* title,
  170. DataLoaderFetch fetcher,
  171. DataLoaderParser parser,
  172. size_t request_count,
  173. ViewNavigationCallback back,
  174. uint32_t view_id);
  175. void web_crawler_loader_draw_callback(Canvas* canvas, void* model);
  176. void web_crawler_loader_init(View* view);
  177. void web_crawler_loader_free_model(View* view);
  178. bool web_crawler_custom_event_callback(void* context, uint32_t index);
  179. #endif