Skip to content

Commit 99e8ceb

Browse files
committed
* Updated to FuriString
* Build for Unleashed and Official firmware
1 parent e85da67 commit 99e8ceb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+81
-169
lines changed

application.fam

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ App(
88
"gui",
99
"cli",
1010
"dialogs",
11-
"storage"
11+
"storage",
12+
"input",
13+
"notification"
1214
],
1315
provides=["totp_start"],
1416
stack_size=2 * 1024,
1517
order=20,
1618
fap_category="Misc",
17-
fap_icon="totp_10px.png",
19+
fap_icon="totp_10px.png"
1820
)
1921

2022
App(

scenes/add_new_token/totp_input_text.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_INPUT_TEXT_H_
2-
#define _TOTP_INPUT_TEXT_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include <gui/view.h>
@@ -37,5 +36,3 @@ InputTextSceneState* totp_input_text_activate(InputTextSceneContext* context);
3736
void totp_input_text_render(Canvas* const canvas, InputTextSceneState* text_input_state);
3837
bool totp_input_text_handle_event(PluginEvent* const event, InputTextSceneState* text_input_state);
3938
void totp_input_text_free(InputTextSceneState* state);
40-
41-
#endif

scenes/add_new_token/totp_scene_add_new_token.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "totp_scene_add_new_token.h"
22
#include "../../types/common.h"
3-
#include "../../lib/ui/constants.h"
3+
#include "../../services/ui/constants.h"
44
#include "../scene_director.h"
55
#include "totp_input_text.h"
66
#include "../../types/token_info.h"
7-
#include "../../lib/list/list.h"
8-
#include "../../lib/base32/base32.h"
9-
#include "../../lib/config/config.h"
10-
#include "../../lib/ui/ui_controls.h"
7+
#include "../../services/list/list.h"
8+
#include "../../services/base32/base32.h"
9+
#include "../../services/config/config.h"
10+
#include "../../services/ui/ui_controls.h"
1111
#include "../generate_token/totp_scene_generate_token.h"
1212

1313
#define TOKEN_ALGO_LIST_LENGTH 3

scenes/add_new_token/totp_scene_add_new_token.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_SCENE_ADD_NEW_TOKEN_H_
2-
#define _TOTP_SCENE_ADD_NEW_TOKEN_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include <furi.h>
@@ -17,5 +16,3 @@ void totp_scene_add_new_token_render(Canvas* const canvas, PluginState* plugin_s
1716
bool totp_scene_add_new_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
1817
void totp_scene_add_new_token_deactivate(PluginState* plugin_state);
1918
void totp_scene_add_new_token_free(PluginState* plugin_state);
20-
21-
#endif

scenes/authenticate/totp_scene_authenticate.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "totp_scene_authenticate.h"
22
#include <dialogs/dialogs.h>
33
#include "../../types/common.h"
4-
#include "../../lib/ui/icons.h"
5-
#include "../../lib/ui/constants.h"
6-
#include "../../lib/config/config.h"
4+
#include "../../services/ui/icons.h"
5+
#include "../../services/ui/constants.h"
6+
#include "../../services/config/config.h"
77
#include "../scene_director.h"
88
#include "../totp_scenes_enum.h"
99

scenes/authenticate/totp_scene_authenticate.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_SCENE_AUTHENTICATE_H_
2-
#define _TOTP_SCENE_AUTHENTICATE_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include <furi.h>
@@ -13,5 +12,3 @@ void totp_scene_authenticate_render(Canvas* const canvas, PluginState* plugin_st
1312
bool totp_scene_authenticate_handle_event(PluginEvent* const event, PluginState* plugin_state);
1413
void totp_scene_authenticate_deactivate(PluginState* plugin_state);
1514
void totp_scene_authenticate_free(PluginState* plugin_state);
16-
17-
#endif

scenes/generate_token/totp_scene_generate_token.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "totp_scene_generate_token.h"
55
#include "../../types/token_info.h"
66
#include "../../types/common.h"
7-
#include "../../lib/ui/icons.h"
8-
#include "../../lib/ui/constants.h"
9-
#include "../../lib/totp/totp.h"
10-
#include "../../lib/config/config.h"
7+
#include "../../services/ui/icons.h"
8+
#include "../../services/ui/constants.h"
9+
#include "../../services/totp/totp.h"
10+
#include "../../services/config/config.h"
1111
#include "../scene_director.h"
1212
#include "../token_menu/totp_scene_token_menu.h"
1313

scenes/generate_token/totp_scene_generate_token.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_SCENE_GENERATE_TOKEN_H_
2-
#define _TOTP_SCENE_GENERATE_TOKEN_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include <furi.h>
@@ -17,5 +16,3 @@ void totp_scene_generate_token_render(Canvas* const canvas, PluginState* plugin_
1716
bool totp_scene_generate_token_handle_event(PluginEvent* const event, PluginState* plugin_state);
1817
void totp_scene_generate_token_deactivate(PluginState* plugin_state);
1918
void totp_scene_generate_token_free(PluginState* plugin_state);
20-
21-
#endif

scenes/scene_director.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _SCENE_DIRECTOR_H_
2-
#define _SCENE_DIRECTOR_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include "../types/plugin_state.h"
@@ -12,5 +11,3 @@ void totp_scene_director_init_scenes(PluginState* const plugin_state);
1211
void totp_scene_director_render(Canvas* const canvas, PluginState* const plugin_state);
1312
void totp_scene_director_dispose(PluginState* const plugin_state);
1413
bool totp_scene_director_handle_event(PluginEvent* const event, PluginState* const plugin_state);
15-
16-
#endif

scenes/token_menu/totp_scene_token_menu.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "totp_scene_token_menu.h"
22
#include <gui/gui.h>
33
#include <dialogs/dialogs.h>
4-
#include "../../lib/ui/ui_controls.h"
5-
#include "../../lib/ui/constants.h"
4+
#include "../../services/ui/ui_controls.h"
5+
#include "../../services/ui/constants.h"
66
#include "../scene_director.h"
7-
#include "../../lib/config/config.h"
8-
#include "../../lib/list/list.h"
7+
#include "../../services/config/config.h"
8+
#include "../../services/list/list.h"
99
#include "../../types/token_info.h"
1010
#include "../generate_token/totp_scene_generate_token.h"
1111
#include "../add_new_token/totp_scene_add_new_token.h"

scenes/token_menu/totp_scene_token_menu.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_SCENE_TOKEN_MENU_H_
2-
#define _TOTP_SCENE_TOKEN_MENU_H_
1+
#pragma once
32

43
#include <gui/gui.h>
54
#include <furi.h>
@@ -17,5 +16,3 @@ void totp_scene_token_menu_render(Canvas* const canvas, PluginState* plugin_stat
1716
bool totp_scene_token_menu_handle_event(PluginEvent* const event, PluginState* plugin_state);
1817
void totp_scene_token_menu_deactivate(PluginState* plugin_state);
1918
void totp_scene_token_menu_free(PluginState* plugin_state);
20-
21-
#endif

scenes/totp_scenes_enum.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#ifndef _TOTP_SCENES_ENUM_H_
2-
#define _TOTP_SCENES_ENUM_H_
1+
#pragma once
2+
33
typedef enum {
44
TotpSceneAuthentication,
55
TotpSceneGenerateToken,
66
TotpSceneAddNewToken,
77
TotpSceneTokenMenu
88
} Scene;
9-
#endif
File renamed without changes.

lib/base32/base32.h services/base32/base32.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
// All functions return the number of output bytes or -1 on error. If the
2626
// output buffer is too small, the result will silently be truncated.
2727

28-
#ifndef _BASE32_H_
29-
#define _BASE32_H_
28+
#pragma once
3029

3130
#include <stdint.h>
3231

@@ -35,5 +34,3 @@ int base32_decode(const uint8_t *encoded, uint8_t *result, int bufSize)
3534
int base32_encode(const uint8_t *data, int length, uint8_t *result,
3635
int bufSize)
3736
__attribute__((visibility("hidden")));
38-
39-
#endif /* _BASE32_H_ */

lib/config/config.c services/config/config.c

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "config.h"
22
#include <stdlib.h>
33
#include <string.h>
4+
#include "../list/list.h"
45
#include "../../types/common.h"
56
#include "../../types/token_info.h"
67
#include "migrations/config_migration_v1_to_v2.h"
@@ -39,12 +40,12 @@ char* token_info_get_algo_as_cstr(TokenInfo* token_info) {
3940
return NULL;
4041
}
4142

42-
void token_info_set_algo_from_str(TokenInfo* token_info, string_t str) {
43-
if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
43+
void token_info_set_algo_from_str(TokenInfo* token_info, FuriString* str) {
44+
if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME) == 0) {
4445
token_info->algo = SHA1;
45-
} else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) {
46+
} else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME)) {
4647
token_info->algo = SHA256;
47-
} else if (string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) {
48+
} else if (furi_string_cmpi_str(str, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME)) {
4849
token_info->algo = SHA512;
4950
}
5051
}
@@ -88,37 +89,36 @@ FlipperFormat* totp_open_config_file(Storage* storage) {
8889
flipper_format_write_comment_cstr(fff_data_file, " ");
8990
flipper_format_write_comment_cstr(fff_data_file, "Timezone offset in hours. Important note: do not put '+' sign for positive values");
9091
flipper_format_write_float(fff_data_file, TOTP_CONFIG_KEY_TIMEZONE, &tmp_tz, 1);
91-
string_t temp_str;
92-
string_init(temp_str);
92+
FuriString* temp_str = furi_string_alloc();
9393

9494
flipper_format_write_comment_cstr(fff_data_file, " ");
9595
flipper_format_write_comment_cstr(fff_data_file, "=== TOKEN SAMPLE BEGIN ===");
9696
flipper_format_write_comment_cstr(fff_data_file, " ");
9797
flipper_format_write_comment_cstr(fff_data_file, "# Token name which will be visible in the UI.");
98-
string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME);
98+
furi_string_printf(temp_str, "%s: Sample token name", TOTP_CONFIG_KEY_TOKEN_NAME);
9999
flipper_format_write_comment(fff_data_file, temp_str);
100100
flipper_format_write_comment_cstr(fff_data_file, " ");
101101

102102
flipper_format_write_comment_cstr(fff_data_file, "# Plain token secret without spaces, dashes and etc, just pure alpha-numeric characters. Important note: plain token will be encrypted and replaced by TOTP app");
103-
string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET);
103+
furi_string_printf(temp_str, "%s: plaintokensecret", TOTP_CONFIG_KEY_TOKEN_SECRET);
104104
flipper_format_write_comment(fff_data_file, temp_str);
105105
flipper_format_write_comment_cstr(fff_data_file, " ");
106106

107-
string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
107+
furi_string_printf(temp_str, " # Token hashing algorithm to use during code generation. Supported options are %s, %s and %s. If you are not use which one to use - use %s", TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
108108
flipper_format_write_comment(fff_data_file, temp_str);
109-
string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
109+
furi_string_printf(temp_str, "%s: %s", TOTP_CONFIG_KEY_TOKEN_ALGO, TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME);
110110
flipper_format_write_comment(fff_data_file, temp_str);
111111
flipper_format_write_comment_cstr(fff_data_file, " ");
112112

113113
flipper_format_write_comment_cstr(fff_data_file, "# How many digits there should be in generated code. Available options are 6 and 8. Majority websites requires 6 digits code, however some rare websites wants to get 8 digits code. If you are not sure which one to use - use 6");
114-
string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS);
114+
furi_string_printf(temp_str, "%s: 6", TOTP_CONFIG_KEY_TOKEN_DIGITS);
115115
flipper_format_write_comment(fff_data_file, temp_str);
116116
flipper_format_write_comment_cstr(fff_data_file, " ");
117117

118118
flipper_format_write_comment_cstr(fff_data_file, "=== TOKEN SAMPLE END ===");
119119
flipper_format_write_comment_cstr(fff_data_file, " ");
120120

121-
string_clear(temp_str);
121+
furi_string_free(temp_str);
122122
if(!flipper_format_rewind(fff_data_file)) {
123123
totp_close_config_file(fff_data_file);
124124
FURI_LOG_E(LOGGING_TAG, "Rewind error");
@@ -163,13 +163,12 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
163163

164164
plugin_state->timezone_offset = 0;
165165

166-
string_t temp_str;
167-
string_init(temp_str);
166+
FuriString* temp_str = furi_string_alloc();
168167

169168
uint32_t file_version;
170169
if(!flipper_format_read_header(fff_data_file, temp_str, &file_version)) {
171170
FURI_LOG_E(LOGGING_TAG, "Missing or incorrect header");
172-
string_clear(temp_str);
171+
furi_string_free(temp_str);
173172
return;
174173
}
175174

@@ -227,7 +226,7 @@ void totp_config_file_load_base(PluginState* const plugin_state) {
227226
FURI_LOG_D(LOGGING_TAG, "Missing timezone offset information, defaulting to 0");
228227
}
229228

230-
string_clear(temp_str);
229+
furi_string_free(temp_str);
231230
totp_close_config_file(fff_data_file);
232231
totp_close_storage();
233232
}
@@ -236,13 +235,12 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
236235
Storage* storage = totp_open_storage();
237236
FlipperFormat* fff_data_file = totp_open_config_file(storage);
238237

239-
string_t temp_str;
238+
FuriString* temp_str = furi_string_alloc();
240239
uint32_t temp_data32;
241-
string_init(temp_str);
242240

243241
if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) {
244242
FURI_LOG_E(LOGGING_TAG, "Missing or incorrect header");
245-
string_clear(temp_str);
243+
furi_string_free(temp_str);
246244
return;
247245
}
248246

@@ -256,7 +254,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
256254

257255
TokenInfo* tokenInfo = token_info_alloc();
258256

259-
const char* temp_cstr = string_get_cstr(temp_str);
257+
const char* temp_cstr = furi_string_get_cstr(temp_str);
260258
tokenInfo->name = (char *)malloc(strlen(temp_cstr) + 1);
261259
strcpy(tokenInfo->name, temp_cstr);
262260

@@ -272,7 +270,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
272270
continue;
273271
}
274272

275-
temp_cstr = string_get_cstr(temp_str);
273+
temp_cstr = furi_string_get_cstr(temp_str);
276274
token_info_set_secret(tokenInfo, temp_cstr, strlen(temp_cstr), &plugin_state->iv[0]);
277275
has_any_plain_secret = true;
278276
FURI_LOG_W(LOGGING_TAG, "Found token with plain secret");
@@ -315,7 +313,7 @@ void totp_config_file_load_tokens(PluginState* const plugin_state) {
315313

316314
FURI_LOG_D(LOGGING_TAG, "Found %d tokens", index);
317315

318-
string_clear(temp_str);
316+
furi_string_free(temp_str);
319317
totp_close_config_file(fff_data_file);
320318
totp_close_storage();
321319

lib/config/config.h services/config/config.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_CONFIG_FILE_H_
2-
#define _TOTP_CONFIG_FILE_H_
1+
#pragma once
32

43
#include <flipper_format/flipper_format.h>
54
#include <furi.h>
@@ -15,5 +14,3 @@ void totp_full_save_config_file(PluginState* const plugin_state);
1514
void totp_config_file_load_base(PluginState* const plugin_state);
1615
void totp_config_file_load_tokens(PluginState* const plugin_state);
1716
void totp_config_file_save_new_token(FlipperFormat* file, TokenInfo* token_info);
18-
19-
#endif

lib/config/constants.h services/config/constants.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef _TOTP_CONFIG_CONSTANTS_FILE_H_
2-
#define _TOTP_CONFIG_CONSTANTS_FILE_H_
1+
#pragma once
32

43
#define CONFIG_FILE_HEADER "Flipper TOTP plugin config file"
54
#define CONFIG_FILE_ACTUAL_VERSION 2
@@ -15,5 +14,3 @@
1514
#define TOTP_CONFIG_TOKEN_ALGO_SHA1_NAME "sha1"
1615
#define TOTP_CONFIG_TOKEN_ALGO_SHA256_NAME "sha256"
1716
#define TOTP_CONFIG_TOKEN_ALGO_SHA512_NAME "sha512"
18-
19-
#endif

lib/config/migrations/config_migration_v1_to_v2.c services/config/migrations/config_migration_v1_to_v2.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file) {
88
flipper_format_write_header_cstr(fff_data_file, CONFIG_FILE_HEADER, NEW_VERSION);
99

10-
string_t temp_str;
11-
string_init(temp_str);
10+
FuriString* temp_str = furi_string_alloc();
1211

1312
if (flipper_format_read_string(fff_backup_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str)) {
1413
flipper_format_write_string(fff_data_file, TOTP_CONFIG_KEY_BASE_IV, temp_str);
@@ -37,6 +36,6 @@ bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* f
3736
flipper_format_write_uint32(fff_data_file, TOTP_CONFIG_KEY_TOKEN_DIGITS, &default_digits, 1);
3837
}
3938

40-
string_clear(temp_str);
39+
furi_string_free(temp_str);
4140
return true;
4241
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#ifndef _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_
2-
#define _TOTP_CONFIG_FILE_MIGRATE_V1_TO_V2_H_
1+
#pragma once
32

43
#include <flipper_format/flipper_format.h>
54

65
bool totp_config_migrate_v1_to_v2(FlipperFormat* fff_data_file, FlipperFormat* fff_backup_data_file);
7-
8-
#endif
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#ifndef BYTESWAP_H
2-
#define BYTESWAP_H
1+
#pragma once
32

43
#include <stdint.h>
54

65
uint32_t swap_uint32( uint32_t val );
76
uint64_t swap_uint64( uint64_t val );
8-
9-
#endif
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)