/* * Copyright (c) 2021, timmot * Copyright (c) 2022, Mustafa Quraish * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include namespace FileSystemAccessClient { using Result = ErrorOr>; class Client final : public IPC::ConnectionToServer , public FileSystemAccessClientEndpoint { IPC_CLIENT_CONNECTION(Client, "/tmp/portal/filesystemaccess") public: Result try_request_file_read_only_approved(GUI::Window* parent_window, String const& path); Result try_request_file(GUI::Window* parent_window, String const& path, Core::OpenMode mode); Result try_open_file(GUI::Window* parent_window, String const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::OpenMode requested_access = Core::OpenMode::ReadOnly); Result try_save_file(GUI::Window* parent_window, String const& name, String const ext, Core::OpenMode requested_access = Core::OpenMode::WriteOnly | Core::OpenMode::Truncate); static Client& the(); protected: void die() override; private: explicit Client(NonnullOwnPtr socket) : IPC::ConnectionToServer(*this, move(socket)) { } virtual void handle_prompt_end(i32 error, Optional const& fd, Optional const& chosen_file) override; RefPtr> m_promise; GUI::Window* m_parent_window { nullptr }; }; }