item.h 1.5 KB

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