summaryrefslogtreecommitdiff
path: root/Userland/Services/FileSystemAccessServer/ConnectionFromClient.h
blob: 0279d0cec936a22914c2c9344bf6f6f3b536d864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * 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/FileTypeFilter.h>
#include <LibGUI/Forward.h>
#include <LibIPC/ConnectionFromClient.h>

namespace FileSystemAccessServer {

class ConnectionFromClient final
    : public IPC::ConnectionFromClient<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint> {
    C_OBJECT(ConnectionFromClient);

public:
    ~ConnectionFromClient() override = default;

    virtual void die() override;

private:
    explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);

    virtual void request_file_read_only_approved(i32, i32, i32, DeprecatedString const&) override;
    virtual void request_file(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode) override;
    virtual void prompt_open_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode, Optional<Vector<GUI::FileTypeFilter>> const&) override;
    virtual void prompt_save_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode) override;

    void prompt_helper(i32, Optional<DeprecatedString> const&, Core::File::OpenMode);
    RefPtr<GUI::Window> create_dummy_child_window(i32, i32);

    enum class ShouldPrompt {
        No,
        Yes
    };
    void request_file_handler(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode, ShouldPrompt);

    virtual Messages::FileSystemAccessServer::ExposeWindowServerClientIdResponse expose_window_server_client_id() override;

    HashMap<DeprecatedString, Core::File::OpenMode> m_approved_files;
};

}