config.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /**
  8. * @brief Token loading results
  9. */
  10. typedef enum {
  11. /**
  12. * @brief All the tokens loaded successfully
  13. */
  14. TokenLoadingResultSuccess,
  15. /**
  16. * @brief All the tokens loaded, but there are some warnings
  17. */
  18. TokenLoadingResultWarning,
  19. /**
  20. * @brief Tokens not loaded because of error(s)
  21. */
  22. TokenLoadingResultError
  23. } TokenLoadingResult;
  24. /**
  25. * @brief Opens storage record
  26. * @return Storage record
  27. */
  28. Storage* totp_open_storage();
  29. /**
  30. * @brief Closes storage record
  31. */
  32. void totp_close_storage();
  33. /**
  34. * @brief Opens or creates TOTP application standard config file
  35. * @param storage storage record to use
  36. * @return Config file reference
  37. */
  38. FlipperFormat* totp_open_config_file(Storage* storage);
  39. /**
  40. * @brief Closes config file
  41. * @param file config file reference
  42. */
  43. void totp_close_config_file(FlipperFormat* file);
  44. /**
  45. * @brief Saves all the settings and tokens to an application config file
  46. * @param plugin_state application state
  47. */
  48. void totp_full_save_config_file(const PluginState* const plugin_state);
  49. /**
  50. * @brief Loads basic information from an application config file into application state without loading all the tokens
  51. * @param plugin_state application state
  52. */
  53. void totp_config_file_load_base(PluginState* const plugin_state);
  54. /**
  55. * @brief Loads tokens from an application config file into application state
  56. * @param plugin_state application state
  57. * @return Results of the loading
  58. */
  59. TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
  60. /**
  61. * @brief Add new token to the end of the application config file
  62. * @param token_info token information to be saved
  63. */
  64. void totp_config_file_save_new_token(const TokenInfo* token_info);
  65. /**
  66. * @brief Updates timezone offset in an application config file
  67. * @param new_timezone_offset new timezone offset to be set
  68. */
  69. void totp_config_file_update_timezone_offset(float new_timezone_offset);