Skip to content

Commit 12ace98

Browse files
committed
update totp
1 parent 293b36d commit 12ace98

File tree

10 files changed

+64
-6
lines changed

10 files changed

+64
-6
lines changed

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ App(
1515
],
1616
stack_size=2 * 1024,
1717
order=20,
18-
fap_version="4.03",
18+
fap_version="4.10",
1919
fap_author="Alexander Kopachov (@akopachov)",
2020
fap_description="Software-based TOTP authenticator for Flipper Zero device",
2121
fap_weburl="https://github.com/akopachov/flipper-zero_authenticator",

cli/cli.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "commands/reset/reset.h"
1616
#include "commands/automation/automation.h"
1717
#include "commands/details/details.h"
18+
#include "commands/version/version.h"
1819

1920
struct TotpCliContext {
2021
PluginState* plugin_state;
@@ -74,6 +75,8 @@ static void totp_cli_handler(Cli* cli, FuriString* args, void* context) {
7475
furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_DETAILS) == 0 ||
7576
furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_DETAILS_ALT) == 0) {
7677
totp_cli_command_details_handle(plugin_state, args, cli);
78+
} else if(furi_string_cmp_str(cmd, TOTP_CLI_COMMAND_VERSION) == 0) {
79+
totp_cli_command_version_handle();
7780
} else {
7881
totp_cli_print_unknown_command(cmd);
7982
}

cli/commands/automation/automation.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#endif
1313
#define TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY "QWERTY"
1414
#define TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY "AZERTY"
15+
#define TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTZ "QWERTZ"
1516
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT_PREFIX "-k"
1617
#define TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT "layout"
1718

@@ -44,6 +45,7 @@ void totp_cli_command_automation_docopt_options() {
4445
DOCOPT_ARGUMENT(
4546
TOTP_CLI_COMMAND_AUTOMATION_ARG_KB_LAYOUT)) " Automation keyboard layout. Must be one of: " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTY
4647
", " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY
48+
", " TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTZ
4749
"\r\n");
4850
}
4951
#endif
@@ -83,6 +85,9 @@ static void print_kb_layout(AutomationKeyboardLayout layout, const char* color)
8385
case AutomationKeyboardLayoutAZERTY:
8486
layoutToPrint = TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY;
8587
break;
88+
case AutomationKeyboardLayoutQWERTZ:
89+
layoutToPrint = TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTZ;
90+
break;
8691
default:
8792
furi_crash("Unknown automation keyboard layout");
8893
break;
@@ -98,6 +103,8 @@ static bool
98103
*out = AutomationKeyboardLayoutQWERTY;
99104
} else if(furi_string_cmpi_str(str, TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_AZERTY) == 0) {
100105
*out = AutomationKeyboardLayoutAZERTY;
106+
} else if(furi_string_cmpi_str(str, TOTP_CLI_COMMAND_AUTOMATION_LAYOUT_QWERTZ) == 0) {
107+
*out = AutomationKeyboardLayoutQWERTZ;
101108
} else {
102109
result = false;
103110
}

cli/commands/help/help.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "../reset/reset.h"
1212
#include "../automation/automation.h"
1313
#include "../details/details.h"
14+
#include "../version/version.h"
1415

1516
#ifdef TOTP_CLI_RICH_HELP_ENABLED
1617
void totp_cli_command_help_docopt_commands() {
@@ -29,6 +30,7 @@ void totp_cli_command_help_handle() {
2930
#ifdef TOTP_CLI_RICH_HELP_ENABLED
3031
TOTP_CLI_PRINTF("Usage:\r\n");
3132
totp_cli_command_help_docopt_usage();
33+
totp_cli_command_version_docopt_usage();
3234
totp_cli_command_list_docopt_usage();
3335
totp_cli_command_details_docopt_usage();
3436
totp_cli_command_add_docopt_usage();
@@ -43,6 +45,7 @@ void totp_cli_command_help_handle() {
4345
cli_nl();
4446
TOTP_CLI_PRINTF("Commands:\r\n");
4547
totp_cli_command_help_docopt_commands();
48+
totp_cli_command_version_docopt_commands();
4649
totp_cli_command_list_docopt_commands();
4750
totp_cli_command_details_docopt_commands();
4851
totp_cli_command_add_docopt_commands();

cli/commands/version/version.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "version.h"
2+
#include "../../cli_helpers.h"
3+
#include "../../../version.h"
4+
5+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
6+
void totp_cli_command_version_docopt_commands() {
7+
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_VERSION " Get application version\r\n");
8+
}
9+
void totp_cli_command_version_docopt_usage() {
10+
TOTP_CLI_PRINTF(" " TOTP_CLI_COMMAND_NAME " " TOTP_CLI_COMMAND_VERSION "\r\n");
11+
}
12+
#endif
13+
14+
void totp_cli_command_version_handle() {
15+
TOTP_CLI_PRINTF(
16+
"%" PRIu8 ".%" PRIu8 ".%" PRIu8 "\r\n",
17+
TOTP_APP_VERSION_MAJOR,
18+
TOTP_APP_VERSION_MINOR,
19+
TOTP_APP_VERSION_PATCH);
20+
}

cli/commands/version/version.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
#include "../../../config/app/config.h"
4+
5+
#define TOTP_CLI_COMMAND_VERSION "version"
6+
7+
void totp_cli_command_version_handle();
8+
#ifdef TOTP_CLI_RICH_HELP_ENABLED
9+
void totp_cli_command_version_docopt_commands();
10+
void totp_cli_command_version_docopt_usage();
11+
#endif

types/automation_kb_layout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ typedef uint8_t AutomationKeyboardLayout;
44

55
enum AutomationKeyboardLayouts {
66
AutomationKeyboardLayoutQWERTY = 0,
7-
AutomationKeyboardLayoutAZERTY = 1
7+
AutomationKeyboardLayoutAZERTY = 1,
8+
AutomationKeyboardLayoutQWERTZ = 2
89
};

ui/scenes/app_settings/totp_app_settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#else
2121
#define AUTOMATION_LIST_MAX_INDEX (1)
2222
#endif
23-
#define BAD_KB_LAYOUT_LIST_MAX_INDEX (1)
23+
#define BAD_KB_LAYOUT_LIST_MAX_INDEX (2)
2424
#define FONT_TEST_STR_LENGTH (7)
2525

2626
static const char* YES_NO_LIST[] = {"NO", "YES"};
@@ -33,7 +33,7 @@ static const char* AUTOMATION_LIST[] = {
3333
"BT and USB"
3434
#endif
3535
};
36-
static const char* BAD_KB_LAYOUT_LIST[] = {"QWERTY", "AZERTY"};
36+
static const char* BAD_KB_LAYOUT_LIST[] = {"QWERTY", "AZERTY", "QWERTZ"};
3737
static const char* FONT_TEST_STR = "0123BCD";
3838

3939
typedef enum {

version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
22

33
#define TOTP_APP_VERSION_MAJOR (4)
4-
#define TOTP_APP_VERSION_MINOR (0)
5-
#define TOTP_APP_VERSION_PATCH (3)
4+
#define TOTP_APP_VERSION_MINOR (1)
5+
#define TOTP_APP_VERSION_PATCH (0)

workers/type_code_common.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ static const uint8_t hid_azerty_keys_map[HID_KEYS_MAP_LENGTH] = {
2525
HID_KEYBOARD_U, HID_KEYBOARD_V, HID_KEYBOARD_Z, HID_KEYBOARD_X, HID_KEYBOARD_Y,
2626
HID_KEYBOARD_W};
2727

28+
static const uint8_t hid_qwertz_keys_map[HID_KEYS_MAP_LENGTH] = {
29+
HID_KEYBOARD_0, HID_KEYBOARD_1, HID_KEYBOARD_2, HID_KEYBOARD_3, HID_KEYBOARD_4,
30+
HID_KEYBOARD_5, HID_KEYBOARD_6, HID_KEYBOARD_7, HID_KEYBOARD_8, HID_KEYBOARD_9,
31+
HID_KEYBOARD_A, HID_KEYBOARD_B, HID_KEYBOARD_C, HID_KEYBOARD_D, HID_KEYBOARD_E,
32+
HID_KEYBOARD_F, HID_KEYBOARD_G, HID_KEYBOARD_H, HID_KEYBOARD_I, HID_KEYBOARD_J,
33+
HID_KEYBOARD_K, HID_KEYBOARD_L, HID_KEYBOARD_M, HID_KEYBOARD_N, HID_KEYBOARD_O,
34+
HID_KEYBOARD_P, HID_KEYBOARD_Q, HID_KEYBOARD_R, HID_KEYBOARD_S, HID_KEYBOARD_T,
35+
HID_KEYBOARD_U, HID_KEYBOARD_V, HID_KEYBOARD_W, HID_KEYBOARD_X, HID_KEYBOARD_Z,
36+
HID_KEYBOARD_Y};
37+
2838
static uint32_t get_keystroke_delay(TokenAutomationFeature features) {
2939
if(features & TokenAutomationFeatureTypeSlower) {
3040
return 100;
@@ -70,6 +80,9 @@ void totp_type_code_worker_execute_automation(
7080
case AutomationKeyboardLayoutAZERTY:
7181
keyboard_layout_dict = &hid_azerty_keys_map[0];
7282
break;
83+
case AutomationKeyboardLayoutQWERTZ:
84+
keyboard_layout_dict = &hid_qwertz_keys_map[0];
85+
break;
7386

7487
default:
7588
return;

0 commit comments

Comments
 (0)