/* * Copyright (c) 2021, timmot * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace FileSystemAccessClient { struct Result { i32 error; Optional fd; Optional chosen_file; }; class Client final : public IPC::ServerConnection , public FileSystemAccessClientEndpoint { C_OBJECT(Client) public: Result request_file_read_only_approved(i32 parent_window_id, String const& path); Result request_file(i32 parent_window_id, String const& path, Core::OpenMode mode); Result open_file(i32 parent_window_id, String const& window_title = {}, StringView const& path = Core::StandardPaths::home_directory()); Result save_file(i32 parent_window_id, String const& name, String const ext); static Client& the(); protected: void die() override; private: explicit Client() : IPC::ServerConnection(*this, "/tmp/portal/filesystemaccess") { } virtual void handle_prompt_end(i32 error, Optional const& fd, Optional const& chosen_file) override; RefPtr> m_promise; }; }