web_crawler_callback.h 6.7 KB

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