archive_i.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. #include "file-worker.h"
  15. #define MAX_DEPTH 32
  16. #define MAX_FILES 100 //temp
  17. #define MAX_FILE_SIZE 128
  18. #define ARCHIVE_FAV_PATH "/any/favorites.txt"
  19. #define ARCHIVE_FAV_TEMP_PATH "/any/favorites.tmp"
  20. typedef enum {
  21. ArchiveViewMain,
  22. ArchiveViewTextInput,
  23. ArchiveViewTotal,
  24. } ArchiveViewEnum;
  25. static const char* flipper_app_name[] = {
  26. [ArchiveFileTypeIButton] = "iButton",
  27. [ArchiveFileTypeNFC] = "NFC",
  28. [ArchiveFileTypeSubGhz] = "Sub-GHz",
  29. [ArchiveFileTypeLFRFID] = "125 kHz RFID",
  30. [ArchiveFileTypeIrda] = "Infrared",
  31. };
  32. static const char* known_ext[] = {
  33. [ArchiveFileTypeIButton] = ".ibtn",
  34. [ArchiveFileTypeNFC] = ".nfc",
  35. [ArchiveFileTypeSubGhz] = ".sub",
  36. [ArchiveFileTypeLFRFID] = ".rfid",
  37. [ArchiveFileTypeIrda] = ".ir",
  38. };
  39. static const char* tab_default_paths[] = {
  40. [ArchiveTabFavorites] = "/any/favorites",
  41. [ArchiveTabIButton] = "/any/ibutton",
  42. [ArchiveTabNFC] = "/any/nfc",
  43. [ArchiveTabSubGhz] = "/any/subghz/saved",
  44. [ArchiveTabLFRFID] = "/any/lfrfid",
  45. [ArchiveTabIrda] = "/any/irda",
  46. [ArchiveTabBrowser] = "/any",
  47. };
  48. static inline const char* get_tab_ext(ArchiveTabEnum tab) {
  49. switch(tab) {
  50. case ArchiveTabIButton:
  51. return known_ext[ArchiveFileTypeIButton];
  52. case ArchiveTabNFC:
  53. return known_ext[ArchiveFileTypeNFC];
  54. case ArchiveTabSubGhz:
  55. return known_ext[ArchiveFileTypeSubGhz];
  56. case ArchiveTabLFRFID:
  57. return known_ext[ArchiveFileTypeLFRFID];
  58. case ArchiveTabIrda:
  59. return known_ext[ArchiveFileTypeIrda];
  60. default:
  61. return "*";
  62. }
  63. }
  64. static inline const char* get_default_path(ArchiveFileTypeEnum type) {
  65. switch(type) {
  66. case ArchiveFileTypeIButton:
  67. return tab_default_paths[ArchiveTabIButton];
  68. case ArchiveFileTypeNFC:
  69. return tab_default_paths[ArchiveTabNFC];
  70. case ArchiveFileTypeSubGhz:
  71. return tab_default_paths[ArchiveTabSubGhz];
  72. case ArchiveFileTypeLFRFID:
  73. return tab_default_paths[ArchiveTabLFRFID];
  74. case ArchiveFileTypeIrda:
  75. return tab_default_paths[ArchiveTabIrda];
  76. default:
  77. return false;
  78. }
  79. }
  80. static inline const char* get_favorites_path() {
  81. return tab_default_paths[ArchiveTabFavorites];
  82. }
  83. typedef enum {
  84. EventTypeTick,
  85. EventTypeKey,
  86. EventTypeExit,
  87. } EventType;
  88. typedef struct {
  89. union {
  90. InputEvent input;
  91. } value;
  92. EventType type;
  93. } AppEvent;
  94. typedef enum {
  95. FavoritesCheck,
  96. FavoritesRead,
  97. FavoritesDelete,
  98. FavoritesRename,
  99. } FavActionsEnum;
  100. typedef struct {
  101. ArchiveTabEnum tab_id;
  102. string_t name;
  103. string_t path;
  104. char text_input_buffer[MAX_NAME_LEN];
  105. uint8_t depth;
  106. uint16_t last_idx[MAX_DEPTH];
  107. bool menu;
  108. } ArchiveBrowser;
  109. struct ArchiveApp {
  110. osMessageQueueId_t event_queue;
  111. FuriThread* app_thread;
  112. Loader* loader;
  113. Gui* gui;
  114. ViewDispatcher* view_dispatcher;
  115. View* view_archive_main;
  116. TextInput* text_input;
  117. Storage* api;
  118. FileWorker* file_worker;
  119. ArchiveBrowser browser;
  120. };