config.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. typedef uint8_t TotpConfigFileOpenResult;
  9. typedef uint8_t TotpConfigFileUpdateResult;
  10. /**
  11. * @brief Token loading results
  12. */
  13. enum TokenLoadingResults {
  14. /**
  15. * @brief All the tokens loaded successfully
  16. */
  17. TokenLoadingResultSuccess,
  18. /**
  19. * @brief All the tokens loaded, but there are some warnings
  20. */
  21. TokenLoadingResultWarning,
  22. /**
  23. * @brief Tokens not loaded because of error(s)
  24. */
  25. TokenLoadingResultError
  26. };
  27. /**
  28. * @brief Config file opening result
  29. */
  30. enum TotpConfigFileOpenResults {
  31. /**
  32. * @brief Config file opened successfully
  33. */
  34. TotpConfigFileOpenSuccess = 0,
  35. /**
  36. * @brief An error has occurred during opening config file
  37. */
  38. TotpConfigFileOpenError = 1
  39. };
  40. /**
  41. * @brief Config file updating result
  42. */
  43. enum TotpConfigFileUpdateResults {
  44. /**
  45. * @brief Config file updated successfully
  46. */
  47. TotpConfigFileUpdateSuccess,
  48. /**
  49. * @brief An error has occurred during updating config file
  50. */
  51. TotpConfigFileUpdateError
  52. };
  53. /**
  54. * @brief Saves all the settings and tokens to an application config file
  55. * @param plugin_state application state
  56. * @return Config file update result
  57. */
  58. TotpConfigFileUpdateResult totp_full_save_config_file(const PluginState* const plugin_state);
  59. /**
  60. * @brief Loads basic information from an application config file into application state without loading all the tokens
  61. * @param plugin_state application state
  62. * @return Config file open result
  63. */
  64. TotpConfigFileOpenResult totp_config_file_load_base(PluginState* const plugin_state);
  65. /**
  66. * @brief Loads tokens from an application config file into application state
  67. * @param plugin_state application state
  68. * @return Results of the loading
  69. */
  70. TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
  71. /**
  72. * @brief Add new token to the end of the application config file
  73. * @param token_info token information to be saved
  74. * @return Config file update result
  75. */
  76. TotpConfigFileUpdateResult totp_config_file_save_new_token(const TokenInfo* token_info);
  77. /**
  78. * @brief Updates timezone offset in an application config file
  79. * @param new_timezone_offset new timezone offset to be set
  80. * @return Config file update result
  81. */
  82. TotpConfigFileUpdateResult totp_config_file_update_timezone_offset(float new_timezone_offset);
  83. /**
  84. * @brief Updates notification method in an application config file
  85. * @param new_notification_method new notification method to be set
  86. * @return Config file update result
  87. */
  88. TotpConfigFileUpdateResult
  89. totp_config_file_update_notification_method(NotificationMethod new_notification_method);
  90. /**
  91. * @brief Updates automation method in an application config file
  92. * @param new_automation_method new automation method to be set
  93. * @return Config file update result
  94. */
  95. TotpConfigFileUpdateResult
  96. totp_config_file_update_automation_method(AutomationMethod new_automation_method);
  97. /**
  98. * @brief Updates application user settings
  99. * @param plugin_state application state
  100. * @return Config file update result
  101. */
  102. TotpConfigFileUpdateResult totp_config_file_update_user_settings(const PluginState* plugin_state);
  103. /**
  104. * @brief Updates crypto signatures information
  105. * @param plugin_state application state
  106. * @return Config file update result
  107. */
  108. TotpConfigFileUpdateResult
  109. totp_config_file_update_crypto_signatures(const PluginState* plugin_state);
  110. /**
  111. * @brief Reset all the settings to default
  112. */
  113. void totp_config_file_reset();