web_crawler_callback.h 6.9 KB

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