Willy-JL 2 лет назад
Родитель
Сommit
90d1620f27
4 измененных файлов с 14 добавлено и 130 удалено
  1. 10 12
      cli_bridge/cli_control.c
  2. 4 4
      cli_bridge/cligui_main.c
  3. 0 2
      cli_bridge/cligui_main_i.h
  4. 0 112
      cli_bridge/internal_defs.h

+ 10 - 12
cli_bridge/cli_control.c

@@ -3,6 +3,7 @@
 #include <cli/cli.h>
 #include <cli/cli.h>
 #include <cli/cli_i.h>
 #include <cli/cli_i.h>
 #include <cli/cli_vcp.h>
 #include <cli/cli_vcp.h>
+#include <furi/core/thread_i.h>
 #include "cligui_main_i.h"
 #include "cligui_main_i.h"
 #include <FreeRTOS.h>
 #include <FreeRTOS.h>
 
 
@@ -34,11 +35,10 @@ static size_t real_rx_handler(uint8_t* buffer, size_t size, uint32_t timeout) {
     return rx_cnt;
     return rx_cnt;
 }
 }
 
 
-static CliCommand_internal* getInternalCliCommand(Cli* cli, const char* name) {
+static CliCommand* getCliCommand(Cli* cli, const char* name) {
     FuriString* target_command = furi_string_alloc();
     FuriString* target_command = furi_string_alloc();
     furi_string_set_str(target_command, name);
     furi_string_set_str(target_command, name);
-    CliCommand_internal* command =
-        CliCommandTree_internal_get(((Cli_internal*)cli)->commands, target_command);
+    CliCommand* command = CliCommandTree_get(cli->commands, target_command);
     furi_string_free(target_command);
     furi_string_free(target_command);
     return command;
     return command;
 }
 }
@@ -54,12 +54,12 @@ static CliSession session;
 void latch_tx_handler() {
 void latch_tx_handler() {
     Cli* global_cli = furi_record_open(RECORD_CLI);
     Cli* global_cli = furi_record_open(RECORD_CLI);
 
 
-    CliCommand_internal* help_command = getInternalCliCommand(global_cli, "help");
+    CliCommand* help_command = getCliCommand(global_cli, "help");
     cliThread = help_command->context;
     cliThread = help_command->context;
 
 
     furi_thread_set_stdout_callback(tx_handler_stdout);
     furi_thread_set_stdout_callback(tx_handler_stdout);
     if(cliThread != NULL) {
     if(cliThread != NULL) {
-        ((FuriThread_internal*)cliThread)->output.write_callback = &tx_handler_stdout;
+        cliThread->output.write_callback = &tx_handler_stdout;
     }
     }
 
 
     rx_stream = furi_stream_buffer_alloc(128, 1);
     rx_stream = furi_stream_buffer_alloc(128, 1);
@@ -75,9 +75,8 @@ void latch_tx_handler() {
     cli_session_open(global_cli, &session);
     cli_session_open(global_cli, &session);
     // Unlock loader-lock
     // Unlock loader-lock
     Loader* loader = furi_record_open(RECORD_LOADER);
     Loader* loader = furi_record_open(RECORD_LOADER);
-    Loader_internal* loader_i = (Loader_internal*)loader;
-    prev_appthread = loader_i->app.thread;
-    loader_i->app.thread = NULL;
+    prev_appthread = loader->app.thread;
+    loader->app.thread = NULL;
     furi_record_close(RECORD_LOADER);
     furi_record_close(RECORD_LOADER);
     furi_record_close(RECORD_CLI);
     furi_record_close(RECORD_CLI);
 }
 }
@@ -85,7 +84,7 @@ void unlatch_tx_handler(bool persist) {
     Cli* global_cli = furi_record_open(RECORD_CLI);
     Cli* global_cli = furi_record_open(RECORD_CLI);
     // Stash cliThread if not null
     // Stash cliThread if not null
     if(cliThread != NULL) {
     if(cliThread != NULL) {
-        CliCommand_internal* help_command = getInternalCliCommand(global_cli, "help");
+        CliCommand* help_command = getCliCommand(global_cli, "help");
         help_command->context = cliThread;
         help_command->context = cliThread;
     }
     }
     // Switch to new session
     // Switch to new session
@@ -103,14 +102,13 @@ void unlatch_tx_handler(bool persist) {
     furi_stream_buffer_send(rx_stream, "_", 1, FuriWaitForever);
     furi_stream_buffer_send(rx_stream, "_", 1, FuriWaitForever);
     // Reconfigure stdout_callback to cli_vcp
     // Reconfigure stdout_callback to cli_vcp
     if(cliThread != NULL) {
     if(cliThread != NULL) {
-        ((FuriThread_internal*)cliThread)->output.write_callback = cli_vcp.tx_stdout;
+        cliThread->output.write_callback = cli_vcp.tx_stdout;
     }
     }
     // At this point, all cli_vcp functions should be back.
     // At this point, all cli_vcp functions should be back.
     furi_stream_buffer_free(rx_stream);
     furi_stream_buffer_free(rx_stream);
     furi_stream_buffer_free(tx_stream);
     furi_stream_buffer_free(tx_stream);
     // Re-lock loader (to avoid crash on automatic unlock)
     // Re-lock loader (to avoid crash on automatic unlock)
     Loader* loader = furi_record_open(RECORD_LOADER);
     Loader* loader = furi_record_open(RECORD_LOADER);
-    Loader_internal* loader_i = (Loader_internal*)loader;
-    loader_i->app.thread = prev_appthread;
+    loader->app.thread = prev_appthread;
     furi_record_close(RECORD_LOADER);
     furi_record_close(RECORD_LOADER);
 }
 }

+ 4 - 4
cli_bridge/cligui_main.c

@@ -2,6 +2,8 @@
 #include "cli_control.h"
 #include "cli_control.h"
 #include "text_input.h"
 #include "text_input.h"
 #include "console_output.h"
 #include "console_output.h"
+#include <loader/loader_i.h>
+#include <gui/view_dispatcher_i.h>
 
 
 static bool cligui_custom_event_cb(void* context, uint32_t event) {
 static bool cligui_custom_event_cb(void* context, uint32_t event) {
     UNUSED(event);
     UNUSED(event);
@@ -74,11 +76,9 @@ int32_t cligui_main(void* p) {
 
 
     cligui->gui = furi_record_open(RECORD_GUI);
     cligui->gui = furi_record_open(RECORD_GUI);
     cligui->view_dispatcher = view_dispatcher_alloc();
     cligui->view_dispatcher = view_dispatcher_alloc();
-    cligui->view_dispatcher_i = (ViewDispatcher_internal*)(cligui->view_dispatcher);
-    prev_input_callback =
-        ((ViewPort_internal*)cligui->view_dispatcher_i->view_port)->input_callback;
+    prev_input_callback = cligui->view_dispatcher->view_port->input_callback;
     view_port_input_callback_set(
     view_port_input_callback_set(
-        cligui->view_dispatcher_i->view_port, input_callback_wrapper, cligui);
+        cligui->view_dispatcher->view_port, input_callback_wrapper, cligui);
     view_dispatcher_enable_queue(cligui->view_dispatcher);
     view_dispatcher_enable_queue(cligui->view_dispatcher);
     view_dispatcher_set_event_callback_context(cligui->view_dispatcher, cligui);
     view_dispatcher_set_event_callback_context(cligui->view_dispatcher, cligui);
     view_dispatcher_set_custom_event_callback(cligui->view_dispatcher, cligui_custom_event_cb);
     view_dispatcher_set_custom_event_callback(cligui->view_dispatcher, cligui_custom_event_cb);

+ 0 - 2
cli_bridge/cligui_main_i.h

@@ -11,7 +11,6 @@
 #include <gui/modules/text_input.h>
 #include <gui/modules/text_input.h>
 #include <m-dict.h>
 #include <m-dict.h>
 #include <loader/loader.h>
 #include <loader/loader.h>
-#include "internal_defs.h"
 
 
 #define TEXT_BOX_STORE_SIZE (4096)
 #define TEXT_BOX_STORE_SIZE (4096)
 #define TEXT_INPUT_STORE_SIZE (512)
 #define TEXT_INPUT_STORE_SIZE (512)
@@ -37,5 +36,4 @@ typedef struct {
     char text_input_store[TEXT_INPUT_STORE_SIZE + 1];
     char text_input_store[TEXT_INPUT_STORE_SIZE + 1];
     TextInput* text_input;
     TextInput* text_input;
     ViewDispatcher* view_dispatcher;
     ViewDispatcher* view_dispatcher;
-    ViewDispatcher_internal* view_dispatcher_i;
 } CliguiApp;
 } CliguiApp;

+ 0 - 112
cli_bridge/internal_defs.h

@@ -1,112 +0,0 @@
-#pragma once
-#include <furi.h>
-#include <furi_hal.h>
-#include <m-dict.h>
-#include <m-bptree.h>
-#include <m-array.h>
-#include <cli/cli.h>
-
-typedef struct {
-    FuriThreadStdoutWriteCallback write_callback;
-    FuriString* buffer;
-} FuriThreadStdout_internal;
-
-typedef struct {
-    bool is_service;
-    FuriThreadState state;
-    int32_t ret;
-
-    FuriThreadCallback callback;
-    void* context;
-
-    FuriThreadStateCallback state_callback;
-    void* state_context;
-
-    char* name;
-    configSTACK_DEPTH_TYPE stack_size;
-    FuriThreadPriority priority;
-
-    TaskHandle_t task_handle;
-    bool heap_trace_enabled;
-    size_t heap_size;
-
-    FuriThreadStdout_internal output;
-} FuriThread_internal;
-
-DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
-typedef struct {
-    FuriMessageQueue* queue;
-    Gui* gui;
-    ViewPort* view_port;
-    ViewDict_t views;
-
-    View* current_view;
-
-    View* ongoing_input_view;
-    uint8_t ongoing_input;
-
-    ViewDispatcherCustomEventCallback custom_event_callback;
-    ViewDispatcherNavigationEventCallback navigation_event_callback;
-    ViewDispatcherTickEventCallback tick_event_callback;
-    uint32_t tick_period;
-    void* event_context;
-} ViewDispatcher_internal;
-
-typedef struct {
-    Gui* gui;
-    bool is_enabled;
-    ViewPortOrientation orientation;
-
-    uint8_t width;
-    uint8_t height;
-
-    ViewPortDrawCallback draw_callback;
-    void* draw_callback_context;
-
-    ViewPortInputCallback input_callback;
-    void* input_callback_context;
-} ViewPort_internal;
-
-typedef struct {
-    char* args;
-    FuriThread* thread;
-    bool insomniac;
-    void* fap;
-} LoaderAppData_internal;
-
-typedef struct {
-    void* pubsub;
-    void* queue;
-    void* loader_menu;
-    void* loader_applications;
-    LoaderAppData_internal app;
-} Loader_internal;
-
-
-typedef struct {
-    CliCallback callback;
-    void* context;
-    uint32_t flags;
-} CliCommand_internal;
-
-#define CLI_COMMANDS_TREE_RANK 4
-BPTREE_DEF2(
-    CliCommandTree_internal,
-    CLI_COMMANDS_TREE_RANK,
-    FuriString*,
-    FURI_STRING_OPLIST,
-    CliCommand_internal,
-    M_POD_OPLIST)
-
-#define M_OPL_CliCommandTree_internal_t() BPTREE_OPLIST(CliCommandTree_internal, M_POD_OPLIST)
-
-typedef struct {
-    CliCommandTree_internal_t commands;
-    void* mutex;
-    void* idle_sem;
-    void* last_line;
-    void* line;
-    void* session;
-
-    size_t cursor_position;
-} Cli_internal;