mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
This commit does three things atomically: - switch over Core::Account+SystemServer+LoginServer to sid based socket names. - change socket names with %uid to %sid. - add/update necessary pledges and unveils. Userland: Switch over servers to sid based sockets Userland: Properly pledge and unveil for sid based sockets
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2021, timmot <tiwwot@protonmail.com>
|
|
* Copyright (c) 2022, Mustafa Quraish <mustafa@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <FileSystemAccessServer/FileSystemAccessClientEndpoint.h>
|
|
#include <FileSystemAccessServer/FileSystemAccessServerEndpoint.h>
|
|
#include <LibCore/File.h>
|
|
#include <LibCore/Promise.h>
|
|
#include <LibCore/StandardPaths.h>
|
|
#include <LibGUI/Window.h>
|
|
#include <LibIPC/ConnectionToServer.h>
|
|
|
|
namespace FileSystemAccessClient {
|
|
|
|
using Result = ErrorOr<NonnullRefPtr<Core::File>>;
|
|
|
|
class Client final
|
|
: public IPC::ConnectionToServer<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>
|
|
, public FileSystemAccessClientEndpoint {
|
|
IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/filesystemaccess"sv)
|
|
|
|
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<Core::Stream::LocalSocket> socket)
|
|
: IPC::ConnectionToServer<FileSystemAccessClientEndpoint, FileSystemAccessServerEndpoint>(*this, move(socket))
|
|
{
|
|
}
|
|
|
|
virtual void handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> const& fd, Optional<String> const& chosen_file) override;
|
|
|
|
int get_new_id();
|
|
Result handle_promise(int);
|
|
|
|
struct PromiseAndWindow {
|
|
RefPtr<Core::Promise<Result>> promise {};
|
|
GUI::Window* parent_window { nullptr };
|
|
};
|
|
|
|
HashMap<int, PromiseAndWindow> m_promises {};
|
|
int m_last_id { 0 };
|
|
};
|
|
|
|
}
|