mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-30 04:19:59 -07:00
last one for now, they shall figure their shit out
This commit is contained in:
@@ -33,6 +33,7 @@ Evil_PortalApp* evil_portal_app_alloc() {
|
||||
app->portal_logs = furi_string_alloc();
|
||||
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&evil_portal_scene_handlers, app);
|
||||
@@ -97,6 +98,7 @@ void evil_portal_app_free(Evil_PortalApp* app) {
|
||||
|
||||
// Close records
|
||||
furi_record_close(RECORD_GUI);
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <gui/scene_manager.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
|
||||
#include <assets_icons.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
|
||||
#define NUM_MENU_ITEMS (4)
|
||||
|
||||
#define EVIL_PORTAL_TEXT_BOX_STORE_SIZE (4096)
|
||||
@@ -20,10 +23,14 @@
|
||||
#define SET_AP_CMD "setap"
|
||||
#define RESET_CMD "reset"
|
||||
|
||||
#define EVIL_PORTAL_INDEX_EXTENSION ".html"
|
||||
#define EVIL_PORTAL_BASE_FOLDER "/apps_data/evil_portal/"
|
||||
|
||||
struct Evil_PortalApp {
|
||||
Gui* gui;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
SceneManager* scene_manager;
|
||||
DialogsApp* dialogs;
|
||||
|
||||
FuriString* portal_logs;
|
||||
const char* command_queue[1];
|
||||
|
||||
@@ -8,15 +8,31 @@ static void evil_portal_close_storage() {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
void evil_portal_read_index_html(void* context) {
|
||||
bool evil_portal_read_index_html(void* context) {
|
||||
FuriString* file_path = furi_string_alloc();
|
||||
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
dialog_file_browser_set_basic_options(
|
||||
&browser_options,
|
||||
EVIL_PORTAL_INDEX_EXTENSION,
|
||||
NULL); // TODO configure icon
|
||||
browser_options.base_path = EVIL_PORTAL_BASE_FOLDER;
|
||||
|
||||
Evil_PortalApp* app = context;
|
||||
bool res = dialog_file_browser_show(app->dialogs, file_path, file_path, &browser_options);
|
||||
|
||||
if(!res) {
|
||||
furi_string_free(file_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
Storage* storage = evil_portal_open_storage();
|
||||
FileInfo fi;
|
||||
|
||||
if(storage_common_stat(storage, EVIL_PORTAL_INDEX_SAVE_PATH, &fi) == FSE_OK) {
|
||||
if(storage_common_stat(storage, furi_string_get_cstr(file_path), &fi) == FSE_OK) {
|
||||
File* index_html = storage_file_alloc(storage);
|
||||
if(storage_file_open(
|
||||
index_html, EVIL_PORTAL_INDEX_SAVE_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
index_html, furi_string_get_cstr(file_path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
app->index_html = malloc((size_t)fi.size);
|
||||
uint8_t* buf_ptr = app->index_html;
|
||||
size_t read = 0;
|
||||
@@ -29,6 +45,7 @@ void evil_portal_read_index_html(void* context) {
|
||||
}
|
||||
free(buf_ptr);
|
||||
}
|
||||
furi_string_free(file_path);
|
||||
storage_file_close(index_html);
|
||||
storage_file_free(index_html);
|
||||
} else {
|
||||
@@ -40,6 +57,7 @@ void evil_portal_read_index_html(void* context) {
|
||||
}
|
||||
|
||||
evil_portal_close_storage();
|
||||
return true;
|
||||
}
|
||||
|
||||
void evil_portal_read_ap_name(void* context) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "../evil_portal_app_i.h"
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
#include <lib/toolbox/stream/file_stream.h>
|
||||
#include <stdlib.h>
|
||||
@@ -10,7 +11,7 @@
|
||||
#define EVIL_PORTAL_AP_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/ap.config.txt"
|
||||
#define EVIL_PORTAL_LOG_SAVE_PATH PORTAL_FILE_DIRECTORY_PATH "/logs"
|
||||
|
||||
void evil_portal_read_index_html(void* context);
|
||||
bool evil_portal_read_index_html(void* context);
|
||||
void evil_portal_read_ap_name(void* context);
|
||||
void write_logs(FuriString* portal_logs);
|
||||
char* sequential_file_resolve_path(
|
||||
|
||||
@@ -22,6 +22,8 @@ void evil_portal_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void
|
||||
void evil_portal_scene_console_output_on_enter(void* context) {
|
||||
Evil_PortalApp* app = context;
|
||||
|
||||
bool portal_file_set = false;
|
||||
|
||||
TextBox* text_box = app->text_box;
|
||||
text_box_reset(app->text_box);
|
||||
text_box_set_font(text_box, TextBoxFontText);
|
||||
@@ -63,13 +65,24 @@ void evil_portal_scene_console_output_on_enter(void* context) {
|
||||
}
|
||||
|
||||
if(0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
|
||||
app->command_queue[0] = SET_AP_CMD;
|
||||
app->has_command_queue = true;
|
||||
app->command_index = 0;
|
||||
if(app->show_stopscan_tip) {
|
||||
const char* msg = "Starting portal\nIf no response press\nBACK to return\n";
|
||||
furi_string_cat_str(app->text_box_store, msg);
|
||||
app->text_box_store_strlen += strlen(msg);
|
||||
portal_file_set = evil_portal_read_index_html(context);
|
||||
|
||||
if(portal_file_set) {
|
||||
app->command_queue[0] = SET_AP_CMD;
|
||||
app->has_command_queue = true;
|
||||
app->command_index = 0;
|
||||
if(app->show_stopscan_tip) {
|
||||
const char* msg = "Starting portal\nIf no response press\nBACK to return\n";
|
||||
furi_string_cat_str(app->text_box_store, msg);
|
||||
app->text_box_store_strlen += strlen(msg);
|
||||
}
|
||||
} else {
|
||||
if(app->show_stopscan_tip) {
|
||||
const char* msg = "No portal selected\nShowing current logs\nPress "
|
||||
"BACK to return\n";
|
||||
furi_string_cat_str(app->text_box_store, msg);
|
||||
app->text_box_store_strlen += strlen(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +107,13 @@ void evil_portal_scene_console_output_on_enter(void* context) {
|
||||
|
||||
if(app->is_command && app->selected_tx_string) {
|
||||
if(0 == strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
|
||||
evil_portal_read_index_html(context);
|
||||
if(!portal_file_set) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, Evil_PortalSceneConsoleOutput, 0);
|
||||
view_dispatcher_switch_to_view(
|
||||
app->view_dispatcher, Evil_PortalAppViewConsoleOutput);
|
||||
return;
|
||||
}
|
||||
|
||||
FuriString* data = furi_string_alloc();
|
||||
furi_string_cat(data, "sethtml=");
|
||||
|
||||
Reference in New Issue
Block a user