flip_store_callback.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef FLIP_STORE_CALLBACK_H
  2. #define FLIP_STORE_CALLBACK_H
  3. #include <flip_store.h>
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <stdlib.h>
  7. #include <ctype.h>
  8. #include <stdbool.h>
  9. #include <apps/flip_store_apps.h>
  10. #include <firmwares/flip_store_firmwares.h>
  11. #include <flip_storage/flip_store_storage.h>
  12. #define MAX_LINE_LENGTH 30
  13. extern bool flip_store_app_does_exist;
  14. extern uint32_t selected_firmware_index;
  15. uint32_t callback_to_submenu(void *context);
  16. uint32_t callback_to_submenu_options(void *context);
  17. uint32_t callback_to_firmware_list(void *context);
  18. uint32_t callback_to_app_list(void *context);
  19. uint32_t callback_exit_app(void *context);
  20. void callback_submenu_choices(void *context, uint32_t index);
  21. void free_all_views(FlipStoreApp *app, bool should_free_variable_item_list);
  22. // Add edits by Derek Jamison
  23. typedef enum DataState DataState;
  24. enum DataState
  25. {
  26. DataStateInitial,
  27. DataStateRequested,
  28. DataStateReceived,
  29. DataStateParsed,
  30. DataStateParseError,
  31. DataStateError,
  32. };
  33. typedef enum FlipStoreCustomEvent FlipStoreCustomEvent;
  34. enum FlipStoreCustomEvent
  35. {
  36. FlipStoreCustomEventProcess,
  37. };
  38. typedef struct DataLoaderModel DataLoaderModel;
  39. typedef bool (*DataLoaderFetch)(DataLoaderModel *model);
  40. typedef char *(*DataLoaderParser)(DataLoaderModel *model);
  41. struct DataLoaderModel
  42. {
  43. char *title;
  44. char *data_text;
  45. DataState data_state;
  46. DataLoaderFetch fetcher;
  47. DataLoaderParser parser;
  48. void *parser_context;
  49. size_t request_index;
  50. size_t request_count;
  51. ViewNavigationCallback back_callback;
  52. FuriTimer *timer;
  53. FlipperHTTP *fhttp;
  54. };
  55. void flip_store_generic_switch_to_view(FlipStoreApp *app, char *title, DataLoaderFetch fetcher, DataLoaderParser parser, size_t request_count, ViewNavigationCallback back, uint32_t view_id);
  56. void flip_store_loader_draw_callback(Canvas *canvas, void *model);
  57. void flip_store_loader_init(View *view);
  58. void flip_store_loader_free_model(View *view);
  59. bool flip_store_custom_event_callback(void *context, uint32_t index);
  60. #endif // FLIP_STORE_CALLBACK_H