Skip to content

Commit 8579a75

Browse files
Revert "added dialogue for selecting a portal (#41)" (#42)
This reverts commit 1cfcb85.
1 parent 790a75e commit 8579a75

5 files changed

+22
-70
lines changed

evil_portal_app.c

+5-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ Evil_PortalApp *evil_portal_app_alloc() {
2929
app->sent_html = false;
3030
app->sent_ap = false;
3131
app->sent_reset = false;
32-
app->has_command_queue = false;
32+
app->has_command_queue = false;
3333
app->command_index = 0;
3434
app->portal_logs = furi_string_alloc();
3535

3636
app->gui = furi_record_open(RECORD_GUI);
37-
app->dialogs = furi_record_open(RECORD_DIALOGS);
3837

3938
app->view_dispatcher = view_dispatcher_alloc();
4039
app->scene_manager = scene_manager_alloc(&evil_portal_scene_handlers, app);
@@ -71,7 +70,8 @@ Evil_PortalApp *evil_portal_app_alloc() {
7170
return app;
7271
}
7372

74-
void evil_portal_app_free(Evil_PortalApp *app) {
73+
void evil_portal_app_free(Evil_PortalApp *app) {
74+
7575
// save latest logs
7676
if (furi_string_utf8_length(app->portal_logs) > 0) {
7777
write_logs(app->portal_logs);
@@ -101,18 +101,17 @@ void evil_portal_app_free(Evil_PortalApp *app) {
101101

102102
// Close records
103103
furi_record_close(RECORD_GUI);
104-
furi_record_close(RECORD_DIALOGS);
105104

106105
free(app);
107106
}
108107

109-
int32_t evil_portal_app(void *p) {
108+
int32_t evil_portal_app(void *p) {
110109
UNUSED(p);
111110
Evil_PortalApp *evil_portal_app = evil_portal_app_alloc();
112111

113112
evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);
114113

115-
view_dispatcher_run(evil_portal_app->view_dispatcher);
114+
view_dispatcher_run(evil_portal_app->view_dispatcher);
116115

117116
evil_portal_app_free(evil_portal_app);
118117

evil_portal_app_i.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include <gui/scene_manager.h>
1212
#include <gui/view_dispatcher.h>
1313

14-
#include <assets_icons.h>
15-
#include <dialogs/dialogs.h>
16-
1714
#define NUM_MENU_ITEMS (4)
1815

1916
#define EVIL_PORTAL_TEXT_BOX_STORE_SIZE (4096)
@@ -23,16 +20,12 @@
2320
#define SET_AP_CMD "setap"
2421
#define RESET_CMD "reset"
2522

26-
#define EVIL_PORTAL_INDEX_EXTENSION ".html"
27-
#define EVIL_PORTAL_BASE_FOLDER "/apps_data/evil_portal/"
28-
2923
struct Evil_PortalApp {
3024
Gui *gui;
3125
ViewDispatcher *view_dispatcher;
3226
SceneManager *scene_manager;
33-
DialogsApp *dialogs;
3427

35-
FuriString *portal_logs;
28+
FuriString* portal_logs;
3629
const char *command_queue[1];
3730
int command_index;
3831
bool has_command_queue;

helpers/evil_portal_storage.c

+5-23
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,17 @@ static Storage *evil_portal_open_storage() {
66

77
static void evil_portal_close_storage() { furi_record_close(RECORD_STORAGE); }
88

9-
bool evil_portal_read_index_html(void *context) {
10-
FuriString *file_path = furi_string_alloc();
11-
12-
DialogsFileBrowserOptions browser_options;
13-
dialog_file_browser_set_basic_options(&browser_options,
14-
EVIL_PORTAL_INDEX_EXTENSION,
15-
NULL); // TODO configure icon
16-
browser_options.base_path = EVIL_PORTAL_BASE_FOLDER;
9+
void evil_portal_read_index_html(void *context) {
1710

1811
Evil_PortalApp *app = context;
19-
bool res = dialog_file_browser_show(app->dialogs, file_path, file_path,
20-
&browser_options);
21-
22-
if (!res) {
23-
furi_string_free(file_path);
24-
return false;
25-
}
26-
2712
Storage *storage = evil_portal_open_storage();
2813
FileInfo fi;
2914

30-
if (storage_common_stat(storage, furi_string_get_cstr(file_path), &fi) ==
15+
if (storage_common_stat(storage, EVIL_PORTAL_INDEX_SAVE_PATH, &fi) ==
3116
FSE_OK) {
3217
File *index_html = storage_file_alloc(storage);
33-
if (storage_file_open(index_html, furi_string_get_cstr(file_path),
34-
FSAM_READ, FSOM_OPEN_EXISTING)) {
18+
if (storage_file_open(index_html, EVIL_PORTAL_INDEX_SAVE_PATH, FSAM_READ,
19+
FSOM_OPEN_EXISTING)) {
3520
app->index_html = malloc((size_t)fi.size);
3621
uint8_t *buf_ptr = app->index_html;
3722
size_t read = 0;
@@ -46,7 +31,6 @@ bool evil_portal_read_index_html(void *context) {
4631
}
4732
free(buf_ptr);
4833
}
49-
furi_string_free(file_path);
5034
storage_file_close(index_html);
5135
storage_file_free(index_html);
5236
} else {
@@ -59,7 +43,6 @@ bool evil_portal_read_index_html(void *context) {
5943
}
6044

6145
evil_portal_close_storage();
62-
return true;
6346
}
6447

6548
void evil_portal_read_ap_name(void *context) {
@@ -127,8 +110,7 @@ void write_logs(FuriString *portal_logs) {
127110
File *file = storage_file_alloc(storage);
128111

129112
if (storage_file_open(file, seq_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
130-
storage_file_write(file, furi_string_get_cstr(portal_logs),
131-
furi_string_utf8_length(portal_logs));
113+
storage_file_write(file, furi_string_get_cstr(portal_logs), furi_string_utf8_length(portal_logs));
132114
}
133115
storage_file_close(file);
134116
storage_file_free(file);

helpers/evil_portal_storage.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "../evil_portal_app_i.h"
2-
#include <dialogs/dialogs.h>
32
#include <flipper_format/flipper_format_i.h>
43
#include <lib/toolbox/stream/file_stream.h>
54
#include <stdlib.h>
@@ -11,8 +10,8 @@
1110
#define EVIL_PORTAL_AP_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/ap.config.txt"
1211
#define EVIL_PORTAL_LOG_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/logs"
1312

14-
bool evil_portal_read_index_html(void *context);
13+
void evil_portal_read_index_html(void *context);
1514
void evil_portal_read_ap_name(void *context);
16-
void write_logs(FuriString *portal_logs);
15+
void write_logs(FuriString* portal_logs);
1716
char *sequential_file_resolve_path(Storage *storage, const char *dir,
1817
const char *prefix, const char *extension);

scenes/evil_portal_scene_console_output.c

+9-30
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ void evil_portal_console_output_handle_rx_data_cb(uint8_t *buf, size_t len,
2424
void evil_portal_scene_console_output_on_enter(void *context) {
2525
Evil_PortalApp *app = context;
2626

27-
bool portal_file_set = false;
28-
2927
TextBox *text_box = app->text_box;
3028
text_box_reset(app->text_box);
3129
text_box_set_font(text_box, TextBoxFontText);
@@ -69,26 +67,14 @@ void evil_portal_scene_console_output_on_enter(void *context) {
6967

7068
if (0 ==
7169
strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
72-
73-
portal_file_set = evil_portal_read_index_html(context);
74-
75-
if (portal_file_set) {
76-
app->command_queue[0] = SET_AP_CMD;
77-
app->has_command_queue = true;
78-
app->command_index = 0;
79-
if (app->show_stopscan_tip) {
80-
const char *msg =
81-
"Starting portal\nIf no response press\nBACK to return\n";
82-
furi_string_cat_str(app->text_box_store, msg);
83-
app->text_box_store_strlen += strlen(msg);
84-
}
85-
} else {
86-
if (app->show_stopscan_tip) {
87-
const char *msg = "No portal selected\nShowing current logs\nPress "
88-
"BACK to return\n";
89-
furi_string_cat_str(app->text_box_store, msg);
90-
app->text_box_store_strlen += strlen(msg);
91-
}
70+
app->command_queue[0] = SET_AP_CMD;
71+
app->has_command_queue = true;
72+
app->command_index = 0;
73+
if (app->show_stopscan_tip) {
74+
const char *msg =
75+
"Starting portal\nIf no response press\nBACK to return\n";
76+
furi_string_cat_str(app->text_box_store, msg);
77+
app->text_box_store_strlen += strlen(msg);
9278
}
9379
}
9480

@@ -116,14 +102,7 @@ void evil_portal_scene_console_output_on_enter(void *context) {
116102
if (app->is_command && app->selected_tx_string) {
117103
if (0 ==
118104
strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
119-
120-
if (!portal_file_set) {
121-
scene_manager_set_scene_state(app->scene_manager,
122-
Evil_PortalSceneConsoleOutput, 0);
123-
view_dispatcher_switch_to_view(app->view_dispatcher,
124-
Evil_PortalAppViewConsoleOutput);
125-
return;
126-
}
105+
evil_portal_read_index_html(context);
127106

128107
FuriString *data = furi_string_alloc();
129108
furi_string_cat(data, "sethtml=");

0 commit comments

Comments
 (0)