Просмотр исходного кода

Revert "added dialogue for selecting a portal (#41)" (#42)

This reverts commit 1cfcb852418ee4c609a98e2897f854f47552845f.
bigbrodude6119 2 лет назад
Родитель
Сommit
8579a750f2

+ 5 - 6
evil_portal_app.c

@@ -29,12 +29,11 @@ Evil_PortalApp *evil_portal_app_alloc() {
   app->sent_html = false;
   app->sent_html = false;
   app->sent_ap = false;
   app->sent_ap = false;
   app->sent_reset = false;
   app->sent_reset = false;
-  app->has_command_queue = false;
+  app->has_command_queue = false;  
   app->command_index = 0;
   app->command_index = 0;
   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);
@@ -71,7 +70,8 @@ Evil_PortalApp *evil_portal_app_alloc() {
   return app;
   return app;
 }
 }
 
 
-void evil_portal_app_free(Evil_PortalApp *app) {
+void evil_portal_app_free(Evil_PortalApp *app) {  
+
   // save latest logs
   // save latest logs
   if (furi_string_utf8_length(app->portal_logs) > 0) {
   if (furi_string_utf8_length(app->portal_logs) > 0) {
     write_logs(app->portal_logs);
     write_logs(app->portal_logs);
@@ -101,18 +101,17 @@ 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);
 }
 }
 
 
-int32_t evil_portal_app(void *p) {
+int32_t evil_portal_app(void *p) {  
   UNUSED(p);
   UNUSED(p);
   Evil_PortalApp *evil_portal_app = evil_portal_app_alloc();
   Evil_PortalApp *evil_portal_app = evil_portal_app_alloc();
 
 
   evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);
   evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);
 
 
-  view_dispatcher_run(evil_portal_app->view_dispatcher);
+  view_dispatcher_run(evil_portal_app->view_dispatcher);  
 
 
   evil_portal_app_free(evil_portal_app);
   evil_portal_app_free(evil_portal_app);
 
 

+ 1 - 8
evil_portal_app_i.h

@@ -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,16 +20,12 @@
 #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];
   int command_index;
   int command_index;
   bool has_command_queue;
   bool has_command_queue;

+ 5 - 23
helpers/evil_portal_storage.c

@@ -6,32 +6,17 @@ static Storage *evil_portal_open_storage() {
 
 
 static void evil_portal_close_storage() { furi_record_close(RECORD_STORAGE); }
 static void evil_portal_close_storage() { furi_record_close(RECORD_STORAGE); }
 
 
-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;
+void evil_portal_read_index_html(void *context) {
 
 
   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) ==
+  if (storage_common_stat(storage, EVIL_PORTAL_INDEX_SAVE_PATH, &fi) ==
       FSE_OK) {
       FSE_OK) {
     File *index_html = storage_file_alloc(storage);
     File *index_html = storage_file_alloc(storage);
-    if (storage_file_open(index_html, furi_string_get_cstr(file_path),
-                          FSAM_READ, FSOM_OPEN_EXISTING)) {
+    if (storage_file_open(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;
@@ -46,7 +31,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 {
@@ -59,7 +43,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) {
@@ -127,8 +110,7 @@ void write_logs(FuriString *portal_logs) {
   File *file = storage_file_alloc(storage);
   File *file = storage_file_alloc(storage);
 
 
   if (storage_file_open(file, seq_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
   if (storage_file_open(file, seq_file_path, FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
-    storage_file_write(file, furi_string_get_cstr(portal_logs),
-                       furi_string_utf8_length(portal_logs));
+    storage_file_write(file, furi_string_get_cstr(portal_logs), furi_string_utf8_length(portal_logs));
   }
   }
   storage_file_close(file);
   storage_file_close(file);
   storage_file_free(file);
   storage_file_free(file);

+ 2 - 3
helpers/evil_portal_storage.h

@@ -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,8 +10,8 @@
 #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(Storage *storage, const char *dir,
 char *sequential_file_resolve_path(Storage *storage, const char *dir,
                                    const char *prefix, const char *extension);
                                    const char *prefix, const char *extension);

+ 9 - 30
scenes/evil_portal_scene_console_output.c

@@ -24,8 +24,6 @@ void evil_portal_console_output_handle_rx_data_cb(uint8_t *buf, size_t len,
 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);
@@ -69,26 +67,14 @@ void evil_portal_scene_console_output_on_enter(void *context) {
 
 
     if (0 ==
     if (0 ==
         strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
         strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
-
-      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);
-        }
+      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);
       }
       }
     }
     }
 
 
@@ -116,14 +102,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 ==
     if (0 ==
         strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
         strncmp(SET_HTML_CMD, app->selected_tx_string, strlen(SET_HTML_CMD))) {
-
-      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;
-      }
+      evil_portal_read_index_html(context);
 
 
       FuriString *data = furi_string_alloc();
       FuriString *data = furi_string_alloc();
       furi_string_cat(data, "sethtml=");
       furi_string_cat(data, "sethtml=");