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