archive_i.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "archive.h"
  3. #include <stdint.h>
  4. #include <furi.h>
  5. #include <gui/gui_i.h>
  6. #include <gui/view_dispatcher.h>
  7. #include <gui/modules/text_input.h>
  8. #include <loader/loader.h>
  9. #include <m-string.h>
  10. #include <m-array.h>
  11. #include <storage/storage.h>
  12. #include "archive_views.h"
  13. #include "applications.h"
  14. #define MAX_DEPTH 32
  15. #define MAX_FILES 100 //temp
  16. #define MAX_FILE_SIZE 128
  17. typedef enum {
  18. ArchiveViewMain,
  19. ArchiveViewTextInput,
  20. ArchiveViewTotal,
  21. } ArchiveViewEnum;
  22. static const char* flipper_app_name[] = {
  23. [ArchiveFileTypeIButton] = "iButton",
  24. [ArchiveFileTypeNFC] = "NFC",
  25. [ArchiveFileTypeSubOne] = "Sub-1 GHz",
  26. [ArchiveFileTypeLFRFID] = "125 kHz RFID",
  27. [ArchiveFileTypeIrda] = "Infrared",
  28. };
  29. static const char* known_ext[] = {
  30. [ArchiveFileTypeIButton] = ".ibtn",
  31. [ArchiveFileTypeNFC] = ".nfc",
  32. [ArchiveFileTypeSubOne] = ".sub1",
  33. [ArchiveFileTypeLFRFID] = ".rfid",
  34. [ArchiveFileTypeIrda] = ".ir",
  35. };
  36. static const char* tab_default_paths[] = {
  37. [ArchiveTabFavorites] = "/any/favorites",
  38. [ArchiveTabIButton] = "/any/ibutton",
  39. [ArchiveTabNFC] = "/any/nfc",
  40. [ArchiveTabSubOne] = "/any/subone",
  41. [ArchiveTabLFRFID] = "/any/lfrfid",
  42. [ArchiveTabIrda] = "/any/irda",
  43. [ArchiveTabBrowser] = "/any",
  44. };
  45. static inline const char* get_tab_ext(ArchiveTabEnum tab) {
  46. switch(tab) {
  47. case ArchiveTabIButton:
  48. return known_ext[ArchiveFileTypeIButton];
  49. case ArchiveTabNFC:
  50. return known_ext[ArchiveFileTypeNFC];
  51. case ArchiveTabSubOne:
  52. return known_ext[ArchiveFileTypeSubOne];
  53. case ArchiveTabLFRFID:
  54. return known_ext[ArchiveFileTypeLFRFID];
  55. case ArchiveTabIrda:
  56. return known_ext[ArchiveFileTypeIrda];
  57. default:
  58. return "*";
  59. }
  60. }
  61. static inline const char* get_default_path(ArchiveFileTypeEnum type) {
  62. switch(type) {
  63. case ArchiveFileTypeIButton:
  64. return tab_default_paths[ArchiveTabIButton];
  65. case ArchiveFileTypeNFC:
  66. return tab_default_paths[ArchiveTabNFC];
  67. case ArchiveFileTypeSubOne:
  68. return tab_default_paths[ArchiveTabSubOne];
  69. case ArchiveFileTypeLFRFID:
  70. return tab_default_paths[ArchiveTabLFRFID];
  71. case ArchiveFileTypeIrda:
  72. return tab_default_paths[ArchiveTabIrda];
  73. default:
  74. return false;
  75. }
  76. }
  77. static inline const char* get_favorites_path() {
  78. return tab_default_paths[ArchiveTabFavorites];
  79. }
  80. typedef enum {
  81. EventTypeTick,
  82. EventTypeKey,
  83. EventTypeExit,
  84. } EventType;
  85. typedef struct {
  86. union {
  87. InputEvent input;
  88. } value;
  89. EventType type;
  90. } AppEvent;
  91. typedef struct {
  92. ArchiveTabEnum tab_id;
  93. string_t name;
  94. string_t path;
  95. char text_input_buffer[MAX_NAME_LEN];
  96. uint8_t depth;
  97. uint16_t last_idx[MAX_DEPTH];
  98. bool menu;
  99. } ArchiveBrowser;
  100. struct ArchiveApp {
  101. osMessageQueueId_t event_queue;
  102. FuriThread* app_thread;
  103. Loader* loader;
  104. Gui* gui;
  105. ViewDispatcher* view_dispatcher;
  106. View* view_archive_main;
  107. TextInput* text_input;
  108. Storage* api;
  109. ArchiveBrowser browser;
  110. };