Skip to content

Commit 7b34241

Browse files
authored
Refactoring (#130)
1 parent 0a9cc9e commit 7b34241

File tree

22 files changed

+380
-214
lines changed

22 files changed

+380
-214
lines changed

application.fam

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ App(
1111
"storage",
1212
"input",
1313
"notification",
14-
#ifdef TOTP_BADBT_TYPE_ENABLED
1514
"bt"
16-
#endif
1715
],
1816
stack_size=2 * 1024,
1917
order=20,

cli/commands/reset/reset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "reset.h"
22

33
#include <stdlib.h>
4-
#include <furi/furi.h>
4+
#include <furi/core/string.h>
55
#include "../../cli_helpers.h"
66
#include "../../../services/config/config.h"
77

features_config.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
// Include Bluetooth token input automation
2+
#ifndef TOTP_NO_BADBT_TYPE
23
#define TOTP_BADBT_TYPE_ENABLED
4+
#endif
35

46
// Include token input automation icons on the main screen
7+
#ifndef TOTP_NO_AUTOMATION_ICONS
58
#define TOTP_AUTOMATION_ICONS_ENABLED
9+
#endif
610

711
// List of compatible firmwares
812
#define TOTP_FIRMWARE_OFFICIAL_STABLE (1)
913
#define TOTP_FIRMWARE_OFFICIAL_DEV (2)
1014
#define TOTP_FIRMWARE_XTREME (3)
1115
// End of list
1216

13-
// Target firmware to build for
17+
// Target firmware to build for.
1418
#ifndef TOTP_TARGET_FIRMWARE
19+
// Defaulting to Xtreme if not previously defined
1520
#define TOTP_TARGET_FIRMWARE TOTP_FIRMWARE_XTREME
1621
#endif

lib/polyfills/strnlen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#pragma once
2+
#pragma weak strnlen
3+
14
#include <stddef.h>
25

36
size_t strnlen(const char* s, size_t maxlen);

services/config/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static char* totp_config_file_backup_i(Storage* storage) {
5757
}
5858

5959
if(backup_file_exists ||
60-
!storage_common_copy(storage, CONFIG_FILE_PATH, backup_path) == FSE_OK) {
60+
storage_common_copy(storage, CONFIG_FILE_PATH, backup_path) != FSE_OK) {
6161
FURI_LOG_E(LOGGING_TAG, "Unable to take a backup");
6262
free(backup_path);
6363
return NULL;

services/config/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22

33
#include <flipper_format/flipper_format.h>
4-
#include <furi.h>
54
#include "../../types/plugin_state.h"
65
#include "../../types/token_info.h"
76
#include "constants.h"

services/crypto/crypto.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "crypto.h"
2-
#include <furi.h>
3-
#include <furi_hal.h>
2+
#include <furi_hal_crypto.h>
3+
#include <furi_hal_random.h>
4+
#include <furi_hal_version.h>
45
#include "../config/config.h"
56
#include "../../types/common.h"
67
#include "memset_s.h"

services/totp/totp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#include "totp.h"
22

3-
#include <stdio.h>
43
#include <stdlib.h>
54
#include <stdint.h>
6-
#include <string.h>
75
#include <math.h>
6+
#include <timezone_utils.h>
87
#include "../hmac/hmac_sha1.h"
98
#include "../hmac/hmac_sha256.h"
109
#include "../hmac/hmac_sha512.h"
1110
#include "../hmac/byteswap.h"
12-
#include "../../lib/timezone_utils/timezone_utils.h"
1311

1412
#define HMAC_MAX_RESULT_SIZE HMAC_SHA512_RESULT_SIZE
1513

totp_app.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
#include <furi.h>
2-
#include <furi_hal.h>
31
#include <gui/gui.h>
42
#include <input/input.h>
53
#include <dialogs/dialogs.h>
64
#include <stdlib.h>
7-
#include <flipper_format/flipper_format.h>
85
#include <notification/notification.h>
96
#include <notification/notification_messages.h>
107
#include <dolphin/dolphin.h>
@@ -105,10 +102,6 @@ static bool totp_plugin_state_init(PluginState* const plugin_state) {
105102
}
106103

107104
plugin_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
108-
if(plugin_state->mutex == NULL) {
109-
FURI_LOG_E(LOGGING_TAG, "Cannot create mutex\r\n");
110-
return false;
111-
}
112105

113106
#ifdef TOTP_BADBT_TYPE_ENABLED
114107
if(plugin_state->automation_method & AutomationMethodBadBt) {

types/token_info.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#include "token_info.h"
2-
#include <furi_hal.h>
32
#include <base32.h>
43
#include <base64.h>
54
#include <memset_s.h>
6-
#include <strnlen.h>
75
#include "common.h"
86
#include "../services/crypto/crypto.h"
97

0 commit comments

Comments
 (0)