config.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <flipper_format/flipper_format.h>
  3. #include <furi.h>
  4. #include "../../types/plugin_state.h"
  5. #include "../../types/token_info.h"
  6. #include "constants.h"
  7. typedef uint8_t TokenLoadingResult;
  8. /**
  9. * @brief Token loading results
  10. */
  11. enum TokenLoadingResults {
  12. /**
  13. * @brief All the tokens loaded successfully
  14. */
  15. TokenLoadingResultSuccess,
  16. /**
  17. * @brief All the tokens loaded, but there are some warnings
  18. */
  19. TokenLoadingResultWarning,
  20. /**
  21. * @brief Tokens not loaded because of error(s)
  22. */
  23. TokenLoadingResultError
  24. };
  25. /**
  26. * @brief Opens storage record
  27. * @return Storage record
  28. */
  29. Storage* totp_open_storage();
  30. /**
  31. * @brief Closes storage record
  32. */
  33. void totp_close_storage();
  34. /**
  35. * @brief Opens or creates TOTP application standard config file
  36. * @param storage storage record to use
  37. * @return Config file reference
  38. */
  39. FlipperFormat* totp_open_config_file(Storage* storage);
  40. /**
  41. * @brief Closes config file
  42. * @param file config file reference
  43. */
  44. void totp_close_config_file(FlipperFormat* file);
  45. /**
  46. * @brief Saves all the settings and tokens to an application config file
  47. * @param plugin_state application state
  48. */
  49. void totp_full_save_config_file(const PluginState* const plugin_state);
  50. /**
  51. * @brief Loads basic information from an application config file into application state without loading all the tokens
  52. * @param plugin_state application state
  53. */
  54. void totp_config_file_load_base(PluginState* const plugin_state);
  55. /**
  56. * @brief Loads tokens from an application config file into application state
  57. * @param plugin_state application state
  58. * @return Results of the loading
  59. */
  60. TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
  61. /**
  62. * @brief Add new token to the end of the application config file
  63. * @param token_info token information to be saved
  64. */
  65. void totp_config_file_save_new_token(const TokenInfo* token_info);
  66. /**
  67. * @brief Updates timezone offset in an application config file
  68. * @param new_timezone_offset new timezone offset to be set
  69. */
  70. void totp_config_file_update_timezone_offset(float new_timezone_offset);
  71. /**
  72. * @brief Updates notification method in an application config file
  73. * @param new_notification_method new notification method to be set
  74. */
  75. void totp_config_file_update_notification_method(NotificationMethod new_notification_method);
  76. /**
  77. * @brief Updates application user settings
  78. * @param plugin_state application state
  79. */
  80. void totp_config_file_update_user_settings(const PluginState* plugin_state);