vb_migrate_i.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. //
  3. // VB Lab Migration Assistant for Flipper Zero
  4. // Copyright (C) 2022 cyanic
  5. //
  6. // This program is free software: you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation, either version 3 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. #pragma once
  19. #include <furi.h>
  20. #include <gui/gui.h>
  21. #include <gui/view_dispatcher.h>
  22. #include <gui/scene_manager.h>
  23. #include <gui/modules/popup.h>
  24. #include <gui/modules/submenu.h>
  25. #include <gui/modules/widget.h>
  26. #include <gui/modules/text_input.h>
  27. // #include <gui/modules/dialog_ex.h>
  28. #include "gui/modules/file_select.h"
  29. #include <gui/modules/loading.h>
  30. #include "gui/modules/variable_item_list_ex.h"
  31. #include <notification/notification.h>
  32. #include <dialogs/dialogs.h>
  33. #include "lib/nfc/nfc_worker.h"
  34. #include "vb_migrate.h"
  35. #include "scenes/vb_migrate_scene.h"
  36. #include "vb_tag.h"
  37. #include "vb_migrate_icons.h"
  38. #define VB_MIGRATE_TEMPLATE_NAME "template" NFC_APP_EXTENSION
  39. #define VB_MIGRATE_CAPTURE_FORMAT "%03d%s"
  40. #define VB_MIGRATE_MAX_DEV_NAME_LENGTH (30)
  41. struct VbMigrate {
  42. Gui* gui;
  43. Storage* storage;
  44. DialogsApp* dialogs;
  45. NotificationApp* notifications;
  46. ViewDispatcher* view_dispatcher;
  47. SceneManager* scene_manager;
  48. Submenu* submenu;
  49. Popup* popup;
  50. Widget* widget;
  51. // DialogEx* dialog_ex;
  52. FileSelect* file_select;
  53. TextInput* text_input;
  54. Loading* loading;
  55. VariableItemListEx* variable_list;
  56. NfcWorker* worker;
  57. NfcDevice* nfc_dev;
  58. char text_store[128];
  59. uint8_t captured_pwd[4];
  60. uint8_t captured_uid[7];
  61. bool clear_account_id;
  62. int num_captured;
  63. int next_id;
  64. int num_sent;
  65. VbTagType orig_type;
  66. VbTagType override_type;
  67. const VbTagProduct* orig_product;
  68. };
  69. typedef enum {
  70. VbMigrateViewMenu,
  71. VbMigrateViewPopup,
  72. VbMigrateViewWidget,
  73. VbMigrateViewTextInput,
  74. // VbMigrateViewDialogEx,
  75. VbMigrateViewFileSelect,
  76. VbMigrateViewLoading,
  77. VbMigrateViewVariableItemList,
  78. } VbMigrateView;
  79. typedef enum {
  80. VbMigrateBgTypeNone,
  81. VbMigrateBgTypeLeftButton = 1 << 0,
  82. VbMigrateBgTypeRightButton = 1 << 1,
  83. } VbMigrateBgType;
  84. void vb_migrate_blink_read(VbMigrate* inst);
  85. void vb_migrate_blink_emulate(VbMigrate* inst);
  86. void vb_migrate_blink_stop(VbMigrate* inst);
  87. void vb_migrate_text_store_set(VbMigrate* inst, const char* text, ...);
  88. void vb_migrate_text_store_clear(VbMigrate* inst);
  89. bool vb_migrate_save_nfc(VbMigrate* inst, const char* dev_name, const char* file_name);
  90. bool vb_migrate_load_nfc(VbMigrate* inst, const char* dev_name, const char* file_name);
  91. int vb_migrate_count_captured_mons(VbMigrate* inst, const char* dev_name);
  92. bool vb_migrate_delete(VbMigrate* inst, const char* dev_name, bool whole_vb);
  93. int vb_migrate_get_next_id(VbMigrate* inst, const char* dev_name, int i, bool is_load);
  94. void vb_migrate_show_loading_popup(VbMigrate* inst, bool show);
  95. void vb_migrate_add_bg(Widget* widget, VbMigrateBgType type);