item.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <m-array.h>
  3. // Max length of a filename, final path element only
  4. #define MAX_NAME_LEN 64
  5. #define MAX_EXT_LEN 6
  6. /** Defines an individual item action or item group. Each object contains
  7. * the relevant file and type information needed to both render correctly
  8. * on-screen as well as to perform that action.
  9. */
  10. typedef enum {
  11. Item_SubGhz,
  12. Item_RFID,
  13. Item_IR,
  14. Item_Playlist,
  15. Item_Group,
  16. Item_Settings,
  17. Item_count
  18. } ItemType;
  19. typedef struct Item {
  20. ItemType type;
  21. FuriString* name;
  22. FuriString* path;
  23. char ext[MAX_EXT_LEN + 1];
  24. } Item;
  25. ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
  26. typedef struct ItemsView {
  27. FuriString* name;
  28. FuriString* path;
  29. ItemArray_t items;
  30. } ItemsView;
  31. /** Allocates and returns an ItemsView* which contains the list of
  32. * items to display for the given path. Contains everything needed
  33. * to render a scene_items.
  34. *
  35. * @param context App*
  36. * @param path FuriString*
  37. * @return ItemsView*
  38. */
  39. ItemsView* item_get_items_view_from_path(void* context, const FuriString* path);
  40. /** Free ItemsView
  41. * @param items_view
  42. */
  43. void item_items_view_free(ItemsView* items_view);
  44. /** Prettify the name by removing a leading XX_, only if both X are digits,
  45. * as well as replace all '_' with ' '.
  46. * @param name FuriString*
  47. */
  48. void item_prettify_name(FuriString* name);
  49. /** Return the ItemType enum for the given extension
  50. * @param ext File extension
  51. */
  52. ItemType item_get_item_type_from_extension(const char* ext);