2022-10-12 02:01:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <flipper_format/flipper_format.h>
|
|
|
|
#include <furi.h>
|
|
|
|
#include "../../types/plugin_state.h"
|
|
|
|
#include "../../types/token_info.h"
|
|
|
|
#include "constants.h"
|
|
|
|
|
2022-11-23 22:19:19 +00:00
|
|
|
typedef uint8_t TokenLoadingResult;
|
2022-12-26 20:31:38 +00:00
|
|
|
typedef uint8_t TotpConfigFileOpenResult;
|
|
|
|
typedef uint8_t TotpConfigFileUpdateResult;
|
2022-11-23 22:19:19 +00:00
|
|
|
|
2022-11-17 19:33:31 +00:00
|
|
|
/**
|
|
|
|
* @brief Token loading results
|
|
|
|
*/
|
2022-11-23 22:19:19 +00:00
|
|
|
enum TokenLoadingResults {
|
2022-11-17 19:33:31 +00:00
|
|
|
/**
|
|
|
|
* @brief All the tokens loaded successfully
|
|
|
|
*/
|
2022-10-21 19:56:58 +00:00
|
|
|
TokenLoadingResultSuccess,
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief All the tokens loaded, but there are some warnings
|
|
|
|
*/
|
2022-10-21 19:56:58 +00:00
|
|
|
TokenLoadingResultWarning,
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Tokens not loaded because of error(s)
|
|
|
|
*/
|
2022-10-21 19:56:58 +00:00
|
|
|
TokenLoadingResultError
|
2022-11-23 22:19:19 +00:00
|
|
|
};
|
2022-10-21 19:56:58 +00:00
|
|
|
|
2022-11-17 19:33:31 +00:00
|
|
|
/**
|
2022-12-26 20:31:38 +00:00
|
|
|
* @brief Config file opening result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
enum TotpConfigFileOpenResults {
|
|
|
|
/**
|
|
|
|
* @brief Config file opened successfully
|
|
|
|
*/
|
|
|
|
TotpConfigFileOpenSuccess = 0,
|
2022-11-17 19:33:31 +00:00
|
|
|
|
2022-12-26 20:31:38 +00:00
|
|
|
/**
|
|
|
|
* @brief An error has occurred during opening config file
|
|
|
|
*/
|
|
|
|
TotpConfigFileOpenError = 1
|
|
|
|
};
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
2022-12-26 20:31:38 +00:00
|
|
|
* @brief Config file updating result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
enum TotpConfigFileUpdateResults {
|
|
|
|
/**
|
|
|
|
* @brief Config file updated successfully
|
|
|
|
*/
|
|
|
|
TotpConfigFileUpdateSuccess,
|
2022-11-17 19:33:31 +00:00
|
|
|
|
2022-12-26 20:31:38 +00:00
|
|
|
/**
|
|
|
|
* @brief An error has occurred during updating config file
|
|
|
|
*/
|
|
|
|
TotpConfigFileUpdateError
|
|
|
|
};
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Saves all the settings and tokens to an application config file
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileUpdateResult totp_full_save_config_file(const PluginState* const plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Loads basic information from an application config file into application state without loading all the tokens
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file open result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileOpenResult totp_config_file_load_base(PluginState* const plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Loads tokens from an application config file into application state
|
|
|
|
* @param plugin_state application state
|
|
|
|
* @return Results of the loading
|
|
|
|
*/
|
2022-10-21 19:56:58 +00:00
|
|
|
TokenLoadingResult totp_config_file_load_tokens(PluginState* const plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Add new token to the end of the application config file
|
|
|
|
* @param token_info token information to be saved
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileUpdateResult totp_config_file_save_new_token(const TokenInfo* token_info);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Updates timezone offset in an application config file
|
|
|
|
* @param new_timezone_offset new timezone offset to be set
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileUpdateResult totp_config_file_update_timezone_offset(float new_timezone_offset);
|
2022-11-23 22:19:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Updates notification method in an application config file
|
|
|
|
* @param new_notification_method new notification method to be set
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-23 22:19:19 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileUpdateResult
|
|
|
|
totp_config_file_update_notification_method(NotificationMethod new_notification_method);
|
2022-11-23 22:19:19 +00:00
|
|
|
|
2023-03-21 16:03:53 +00:00
|
|
|
/**
|
|
|
|
* @brief Updates automation method in an application config file
|
|
|
|
* @param new_automation_method new automation method to be set
|
|
|
|
* @return Config file update result
|
|
|
|
*/
|
|
|
|
TotpConfigFileUpdateResult
|
|
|
|
totp_config_file_update_automation_method(AutomationMethod new_automation_method);
|
|
|
|
|
2022-11-23 22:19:19 +00:00
|
|
|
/**
|
|
|
|
* @brief Updates application user settings
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
|
|
|
*/
|
|
|
|
TotpConfigFileUpdateResult totp_config_file_update_user_settings(const PluginState* plugin_state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Updates crypto signatures information
|
|
|
|
* @param plugin_state application state
|
|
|
|
* @return Config file update result
|
2022-11-23 22:19:19 +00:00
|
|
|
*/
|
2022-12-26 20:31:38 +00:00
|
|
|
TotpConfigFileUpdateResult
|
2023-01-06 23:07:26 +00:00
|
|
|
totp_config_file_update_crypto_signatures(const PluginState* plugin_state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reset all the settings to default
|
|
|
|
*/
|
|
|
|
void totp_config_file_reset();
|