item.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_NFC,
  15. Item_iButton,
  16. Item_Playlist,
  17. Item_Group,
  18. Item_Settings,
  19. Item_Unknown,
  20. Item_count
  21. } ItemType;
  22. typedef struct Item {
  23. ItemType type;
  24. FuriString* name;
  25. FuriString* path;
  26. char ext[MAX_EXT_LEN + 1];
  27. } Item;
  28. ARRAY_DEF(ItemArray, Item, M_POD_OPLIST);
  29. typedef struct ItemsView {
  30. FuriString* name;
  31. FuriString* path;
  32. ItemArray_t items;
  33. } ItemsView;
  34. /** Allocates and returns an ItemsView* which contains the list of
  35. * items to display for the given path. Contains everything needed
  36. * to render a scene_items.
  37. *
  38. * @param context App*
  39. * @param path FuriString*
  40. * @return ItemsView*
  41. */
  42. ItemsView* item_get_items_view_from_path(void* context, const FuriString* path);
  43. /** Free ItemsView
  44. * @param items_view
  45. */
  46. void item_items_view_free(ItemsView* items_view);
  47. /** Prettify the name by removing a leading XX_, only if both X are digits,
  48. * as well as replace all '_' with ' '.
  49. * @param name FuriString*
  50. */
  51. void item_prettify_name(FuriString* name);
  52. /** Return the ItemType enum for the given extension
  53. * @param ext File extension
  54. */
  55. ItemType item_get_item_type_from_extension(const char* ext);