web_crawler_callback.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 File Delete 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_file_delete_clicked(void *context, uint32_t index);
  87. void web_crawler_setting_item_file_read_clicked(void *context, uint32_t index);
  88. // Add edits by Derek Jamison
  89. typedef enum DataState DataState;
  90. enum DataState
  91. {
  92. DataStateInitial,
  93. DataStateRequested,
  94. DataStateReceived,
  95. DataStateParsed,
  96. DataStateParseError,
  97. DataStateError,
  98. };
  99. typedef enum WebCrawlerCustomEvent WebCrawlerCustomEvent;
  100. enum WebCrawlerCustomEvent
  101. {
  102. WebCrawlerCustomEventProcess,
  103. };
  104. typedef struct DataLoaderModel DataLoaderModel;
  105. typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
  106. typedef char *(*DataLoaderParser)(DataLoaderModel *model);
  107. struct DataLoaderModel
  108. {
  109. char *title;
  110. char *data_text;
  111. DataState data_state;
  112. DataLoaderFetch fetcher;
  113. DataLoaderParser parser;
  114. void *parser_context;
  115. size_t request_index;
  116. size_t request_count;
  117. ViewNavigationCallback back_callback;
  118. FuriTimer *timer;
  119. FlipperHTTP *fhttp;
  120. };
  121. 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);
  122. void web_crawler_loader_draw_callback(Canvas *canvas, void *model);
  123. void web_crawler_loader_init(View *view);
  124. void web_crawler_loader_free_model(View *view);
  125. bool web_crawler_custom_event_callback(void *context, uint32_t index);
  126. #endif