From 3de8dd921ed3715db5e40f9c0ceb34811d89aaa6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 24 Apr 2023 10:36:53 +0200 Subject: [PATCH] Userland: Remove serialize-to-JSON functions only used for Inspector --- Userland/Libraries/LibCore/Object.cpp | 8 ---- Userland/Libraries/LibCore/Object.h | 2 - Userland/Libraries/LibLine/Editor.cpp | 18 -------- Userland/Libraries/LibLine/Editor.h | 3 -- Userland/Services/SystemServer/Service.cpp | 50 ---------------------- Userland/Services/SystemServer/Service.h | 3 -- Userland/Shell/Shell.cpp | 26 ----------- Userland/Shell/Shell.h | 2 - 8 files changed, 112 deletions(-) diff --git a/Userland/Libraries/LibCore/Object.cpp b/Userland/Libraries/LibCore/Object.cpp index fdc170976b..bc8638740b 100644 --- a/Userland/Libraries/LibCore/Object.cpp +++ b/Userland/Libraries/LibCore/Object.cpp @@ -174,14 +174,6 @@ void Object::deferred_invoke(Function invokee) Core::deferred_invoke([invokee = move(invokee), strong_this = NonnullRefPtr(*this)] { invokee(); }); } -void Object::save_to(JsonObject& json) -{ - for (auto& it : m_properties) { - auto& property = it.value; - json.set(property->name(), property->get()); - } -} - JsonValue Object::property(DeprecatedString const& name) const { auto it = m_properties.find(name); diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index da518e2a31..8e5503776f 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -157,8 +157,6 @@ public: void deferred_invoke(Function); - void save_to(JsonObject&); - bool set_property(DeprecatedString const& name, JsonValue const& value); JsonValue property(DeprecatedString const& name) const; HashMap> const& properties() const { return m_properties; } diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 573467d148..cc3471c813 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -767,24 +767,6 @@ auto Editor::get_line(DeprecatedString const& prompt) -> Result { m_input_error.value() } : Result { m_returned_line }; } -void Editor::save_to(JsonObject& object) -{ - Core::Object::save_to(object); - object.set("is_searching", m_is_searching); - object.set("is_editing", m_is_editing); - object.set("cursor_offset", m_cursor); - object.set("needs_refresh", m_refresh_needed); - object.set("unprocessed_characters", m_incomplete_data.size()); - object.set("history_size", m_history.size()); - object.set("current_prompt", m_new_prompt); - object.set("was_interrupted", m_was_interrupted); - JsonObject display_area; - display_area.set("top_left_row", m_origin_row); - display_area.set("top_left_column", m_origin_column); - display_area.set("line_count", num_lines()); - object.set("used_display_area", move(display_area)); -} - ErrorOr Editor::try_update_once() { if (m_was_interrupted) { diff --git a/Userland/Libraries/LibLine/Editor.h b/Userland/Libraries/LibLine/Editor.h index 5a6ea4e7e4..5aa805157a 100644 --- a/Userland/Libraries/LibLine/Editor.h +++ b/Userland/Libraries/LibLine/Editor.h @@ -266,9 +266,6 @@ private: Retry }; - // FIXME: Port to Core::Property - void save_to(JsonObject&); - ErrorOr try_update_once(); void handle_interrupt_event(); ErrorOr handle_read_event(); diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp index 9928e44207..eda136ce1f 100644 --- a/Userland/Services/SystemServer/Service.cpp +++ b/Userland/Services/SystemServer/Service.cpp @@ -346,56 +346,6 @@ ErrorOr> Service::try_create(Core::ConfigFile const& conf return service; } -void Service::save_to(JsonObject& json) -{ - Core::Object::save_to(json); - - json.set("executable_path", m_executable_path); - - // FIXME: This crashes Inspector. - /* - JsonArray extra_args; - for (String& arg : m_extra_arguments) - extra_args.append(arg); - json.set("extra_arguments", move(extra_args)); - - JsonArray system_modes; - for (String& mode : m_system_modes) - system_modes.append(mode); - json.set("system_modes", system_modes); - - JsonArray environment; - for (String& env : m_environment) - system_modes.append(env); - json.set("environment", environment); - - JsonArray sockets; - for (SocketDescriptor &socket : m_sockets) { - JsonObject socket_obj; - socket_obj.set("path", socket.path); - socket_obj.set("permissions", socket.permissions); - sockets.append(socket); - } - json.set("sockets", sockets); - */ - - json.set("stdio_file_path", m_stdio_file_path); - json.set("priority", m_priority); - json.set("keep_alive", m_keep_alive); - json.set("lazy", m_lazy); - json.set("user", m_user); - json.set("multi_instance", m_multi_instance); - json.set("accept_socket_connections", m_accept_socket_connections); - - if (m_pid > 0) - json.set("pid", m_pid); - else - json.set("pid", nullptr); - - json.set("restart_attempts", m_restart_attempts); - json.set("working_directory", m_working_directory); -} - bool Service::is_enabled() const { extern DeprecatedString g_system_mode; diff --git a/Userland/Services/SystemServer/Service.h b/Userland/Services/SystemServer/Service.h index f2a85b46ed..f0aa9067cc 100644 --- a/Userland/Services/SystemServer/Service.h +++ b/Userland/Services/SystemServer/Service.h @@ -26,9 +26,6 @@ public: static Service* find_by_pid(pid_t); - // FIXME: Port to Core::Property - void save_to(JsonObject&); - private: Service(Core::ConfigFile const&, StringView name); diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 4d27ea2775..7cfd176411 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -2348,32 +2348,6 @@ void Shell::kill_job(Job const* job, int sig) } } -ErrorOr Shell::save_to(JsonObject& object) -{ - Core::Object::save_to(object); - object.set("working_directory", cwd); - object.set("username", username); - object.set("user_home_path", home); - object.set("user_id", uid); - object.set("directory_stack_size", directory_stack.size()); - object.set("cd_history_size", cd_history.size()); - - // Jobs. - JsonArray job_objects; - for (auto& job_entry : jobs) { - JsonObject job_object; - job_object.set("pid", job_entry.value->pid()); - job_object.set("pgid", job_entry.value->pgid()); - job_object.set("running_time", job_entry.value->timer().elapsed()); - job_object.set("command", job_entry.value->cmd()); - job_object.set("is_running_in_background", job_entry.value->is_running_in_background()); - TRY(job_objects.append(move(job_object))); - } - object.set("jobs", move(job_objects)); - - return {}; -} - void Shell::possibly_print_error() const { switch (m_error) { diff --git a/Userland/Shell/Shell.h b/Userland/Shell/Shell.h index 8f4872f05d..19276a9e49 100644 --- a/Userland/Shell/Shell.h +++ b/Userland/Shell/Shell.h @@ -401,8 +401,6 @@ private: bool is_allowed_to_modify_termios(const AST::Command&) const; - // FIXME: Port to Core::Property - ErrorOr save_to(JsonObject&); void bring_cursor_to_beginning_of_a_line() const; Optional resolve_job_spec(StringView);