mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
FileSystemAccessServer: Add service for accessing veiled files nicely
Adds new service FileSystemAccessServer which allows programs to request a file descriptor for any file on the file system. The user can be prompted to choose the path with a FilePicker, or the path can be provided by the application which will show a MessageBox showing the pid and name of the calling process and allows the user to approve or deny the request.
This commit is contained in:
parent
5e823d3de0
commit
41ce2debda
8 changed files with 246 additions and 0 deletions
38
Userland/Services/FileSystemAccessServer/ClientConnection.h
Normal file
38
Userland/Services/FileSystemAccessServer/ClientConnection.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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 <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 Messages::FileSystemAccessServer::RequestFileResponse request_file(String const&, Core::OpenMode const&) override;
|
||||
virtual Messages::FileSystemAccessServer::PromptOpenFileResponse prompt_open_file(String const&, Core::OpenMode const&) override;
|
||||
virtual Messages::FileSystemAccessServer::PromptSaveFileResponse prompt_save_file(String const&, String const&, String const&, Core::OpenMode const&) override;
|
||||
|
||||
template<typename T>
|
||||
T prompt_helper(Optional<String> const&, Core::OpenMode const&);
|
||||
|
||||
HashMap<String, Core::OpenMode> m_approved_files;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue