mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:28:11 +00:00

This transitions from synchronous IPC calls to asynchronous IPC calls provided through a synchronous interface in LibFileSystemAccessClient which allows the parent Application to stay responsive. It achieves this with Promise which is pumping the Application event loop while waiting for the Dialog to respond with the user's action. LibFileSystemAccessClient provides a lazy singleton which also ensures that FileSystemAccessServer is running in the event of a crash. This also transitions TextEditor into using LibFileSystemAccessClient.
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) 2021, timmot <tiwwot@protonmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <FileSystemAccessServer/FileSystemAccessClientEndpoint.h>
|
|
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
|
|
#include <LibCore/Forward.h>
|
|
#include <LibGUI/Forward.h>
|
|
#include <LibIPC/ClientConnection.h>
|
|
|
|
namespace FileSystemAccessServer {
|
|
|
|
class ClientConnection final
|
|
: public IPC::ClientConnection<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint> {
|
|
C_OBJECT(ClientConnection);
|
|
|
|
public:
|
|
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
|
|
~ClientConnection() override;
|
|
|
|
virtual void die() override;
|
|
|
|
private:
|
|
virtual void request_file(i32, i32, String const&, Core::OpenMode const&) override;
|
|
virtual void prompt_open_file(i32, i32, String const&, Core::OpenMode const&) override;
|
|
virtual void prompt_save_file(i32, i32, String const&, String const&, String const&, Core::OpenMode const&) override;
|
|
|
|
void prompt_helper(Optional<String> const&, Core::OpenMode const&);
|
|
RefPtr<GUI::Window> create_dummy_child_window(i32, i32);
|
|
|
|
HashMap<String, Core::OpenMode> m_approved_files;
|
|
};
|
|
|
|
}
|