mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
LibFileSystemAccessClient: Rename try_* functions to try_*_deprecated
These functions return the deprecated `Core::File` class, so let's mark it as such to avoid possible confusion between future non try_* functions which will use Core::Stream family classes and to possibly grab someone's attention. :^)
This commit is contained in:
parent
e361025cfb
commit
247db3fdd0
22 changed files with 38 additions and 38 deletions
|
@ -147,7 +147,7 @@ void GLContextWidget::drop_event(GUI::DropEvent& event)
|
|||
if (url.scheme() != "file")
|
||||
continue;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), url.path(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), url.path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
load_file(response.value());
|
||||
|
@ -339,7 +339,7 @@ bool GLContextWidget::load_file(Core::File& file)
|
|||
if (!bitmap_or_error.is_error())
|
||||
texture_image = bitmap_or_error.release_value_but_fixme_should_propagate_errors();
|
||||
} else {
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), builder.string_view(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), builder.string_view(), Core::OpenMode::ReadOnly);
|
||||
if (!response.is_error()) {
|
||||
auto texture_file = response.value();
|
||||
auto bitmap_or_error = Gfx::Bitmap::try_load_from_fd_and_close(texture_file->leak_fd(), texture_file->filename());
|
||||
|
@ -398,7 +398,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto& file_menu = window->add_menu("&File");
|
||||
|
||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
if (!request_close())
|
||||
return;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window(), {}, Core::StandardPaths::home_directory(), Core::OpenMode::ReadWrite);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window(), {}, Core::StandardPaths::home_directory(), Core::OpenMode::ReadWrite);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -586,7 +586,7 @@ void HexEditorWidget::drop_event(GUI::DropEvent& event)
|
|||
return;
|
||||
|
||||
// TODO: A drop event should be considered user consent for opening a file
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
open_file(response.value());
|
||||
|
|
|
@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (arguments.argc > 1) {
|
||||
// FIXME: Using `try_request_file_read_only_approved` doesn't work here since the file stored in the editor is only readable.
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window, arguments.strings[1], Core::OpenMode::ReadWrite);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window, arguments.strings[1], Core::OpenMode::ReadWrite);
|
||||
if (response.is_error())
|
||||
return 1;
|
||||
hex_editor_widget->open_file(response.value());
|
||||
|
|
|
@ -211,7 +211,7 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
|
|||
{
|
||||
auto& file_menu = window.add_menu("&File");
|
||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(&window);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window);
|
||||
if (!response.is_error())
|
||||
open_file(*response.value());
|
||||
}));
|
||||
|
|
|
@ -47,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
if (file_path) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, file_path);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, file_path);
|
||||
if (response.is_error())
|
||||
return 1;
|
||||
pdf_viewer_widget->open_file(*response.value());
|
||||
|
|
|
@ -710,7 +710,7 @@ void ImageEditor::save_project()
|
|||
save_project_as();
|
||||
return;
|
||||
}
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), path(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), path(), Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
auto result = save_project_to_file(*response.value());
|
||||
|
|
|
@ -192,7 +192,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
});
|
||||
|
||||
m_open_image_action = GUI::CommonActions::make_open_action([&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(&window);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window);
|
||||
if (response.is_error())
|
||||
return;
|
||||
open_image(response.value());
|
||||
|
@ -415,7 +415,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
}));
|
||||
m_edit_menu->add_action(GUI::Action::create(
|
||||
"&Load Color Palette", g_icon_bag.load_color_palette, [&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Load Color Palette");
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window, "Load Color Palette");
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -1264,7 +1264,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
|
|||
if (url.scheme() != "file")
|
||||
continue;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), url.path(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), url.path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
open_image(response.value());
|
||||
|
|
|
@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->show();
|
||||
|
||||
if (image_file) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, image_file);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, image_file);
|
||||
if (response.is_error())
|
||||
return 1;
|
||||
main_widget->open_image(response.value());
|
||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<void> PresenterWidget::initialize_menubar()
|
|||
// Set up the menu bar.
|
||||
auto& file_menu = window->add_menu("&File");
|
||||
auto open_action = GUI::CommonActions::make_open_action([this](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(this->window());
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(this->window());
|
||||
if (response.is_error())
|
||||
return;
|
||||
this->set_file(response.value()->filename());
|
||||
|
|
|
@ -127,14 +127,14 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
if (!request_close())
|
||||
return;
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
|
||||
if (response.is_error())
|
||||
return;
|
||||
load_file(*response.value());
|
||||
});
|
||||
|
||||
m_import_action = GUI::Action::create("Import sheets...", [&](auto&) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -147,7 +147,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe
|
|||
return;
|
||||
}
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), current_filename(), Core::OpenMode::WriteOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), current_filename(), Core::OpenMode::WriteOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
save(*response.value());
|
||||
|
|
|
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->show();
|
||||
|
||||
if (filename) {
|
||||
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, filename));
|
||||
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, filename));
|
||||
spreadsheet_widget->load_file(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ MainWidget::MainWidget()
|
|||
return;
|
||||
}
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -303,7 +303,7 @@ MainWidget::MainWidget()
|
|||
m_save_as_action->activate();
|
||||
return;
|
||||
}
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), m_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), m_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -804,7 +804,7 @@ void MainWidget::drop_event(GUI::DropEvent& event)
|
|||
return;
|
||||
|
||||
// TODO: A drop event should be considered user consent for opening a file
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
read_file(*response.value());
|
||||
|
|
|
@ -74,7 +74,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
if (file_to_edit) {
|
||||
FileArgument parsed_argument(file_to_edit);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, parsed_argument.filename());
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, parsed_argument.filename());
|
||||
|
||||
if (response.is_error()) {
|
||||
if (response.error().code() == ENOENT)
|
||||
|
|
|
@ -238,7 +238,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
if (request_close() == GUI::Window::CloseRequestDecision::StayOpen)
|
||||
return;
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Select theme file", "/res/themes"sv);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(&window, "Select theme file", "/res/themes"sv);
|
||||
if (response.is_error())
|
||||
return;
|
||||
auto load_from_file_result = load_from_file(*response.value());
|
||||
|
@ -250,7 +250,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
|
|||
|
||||
m_save_action = GUI::CommonActions::make_save_action([&](auto&) {
|
||||
if (m_path.has_value()) {
|
||||
auto result = FileSystemAccessClient::Client::the().try_request_file(&window, *m_path, Core::OpenMode::ReadWrite | Core::OpenMode::Truncate);
|
||||
auto result = FileSystemAccessClient::Client::the().try_request_file_deprecated(&window, *m_path, Core::OpenMode::ReadWrite | Core::OpenMode::Truncate);
|
||||
if (result.is_error())
|
||||
return;
|
||||
save_to_file(result.value());
|
||||
|
|
|
@ -170,7 +170,7 @@ void PreviewWidget::drop_event(GUI::DropEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window(), urls.first().path(), Core::OpenMode::ReadOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// Note: This is deferred to ensure that the window has already popped and thus proper window stealing can be performed.
|
||||
app->event_loop().deferred_invoke(
|
||||
[&window, &path, &main_widget]() {
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, path.value());
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, path.value());
|
||||
if (response.is_error())
|
||||
GUI::MessageBox::show_error(window, DeprecatedString::formatted("Opening \"{}\" failed: {}", path.value(), response.error()));
|
||||
else {
|
||||
|
|
|
@ -108,7 +108,7 @@ GalleryWidget::GalleryWidget()
|
|||
m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
m_file_button->on_click = [&](auto) {
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window());
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window());
|
||||
if (response.is_error())
|
||||
return;
|
||||
m_text_editor->set_text(response.release_value()->filename());
|
||||
|
|
|
@ -150,7 +150,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
save_as_action->activate();
|
||||
return;
|
||||
}
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file(window, file_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
auto response = FileSystemAccessClient::Client::the().try_request_file_deprecated(window, file_path, Core::OpenMode::Truncate | Core::OpenMode::WriteOnly);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -171,7 +171,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return;
|
||||
}
|
||||
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file(window);
|
||||
auto response = FileSystemAccessClient::Client::the().try_open_file_deprecated(window);
|
||||
if (response.is_error())
|
||||
return;
|
||||
|
||||
|
@ -295,7 +295,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
editor->set_cursor(4, 28); // after "...widgets!"
|
||||
update_title();
|
||||
} else {
|
||||
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window, path));
|
||||
auto file = TRY(FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window, path));
|
||||
file_path = path;
|
||||
editor->set_text(file->read_all());
|
||||
update_title();
|
||||
|
|
|
@ -67,7 +67,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(game_menu->try_add_separator());
|
||||
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Import PGN...", { Mod_Ctrl, Key_O }, [&](auto&) {
|
||||
auto result = FileSystemAccessClient::Client::the().try_open_file(window);
|
||||
auto result = FileSystemAccessClient::Client::the().try_open_file_deprecated(window);
|
||||
if (result.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Client& Client::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
DeprecatedResult Client::try_request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path)
|
||||
DeprecatedResult Client::try_request_file_read_only_approved_deprecated(GUI::Window* parent_window, DeprecatedString const& path)
|
||||
{
|
||||
auto const id = get_new_id();
|
||||
m_promises.set(id, PromiseAndWindow { { Core::Promise<DeprecatedResult>::construct() }, parent_window });
|
||||
|
@ -69,7 +69,7 @@ static Core::Stream::OpenMode to_stream_open_mode(Core::OpenMode open_mode)
|
|||
return result;
|
||||
}
|
||||
|
||||
DeprecatedResult Client::try_request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::OpenMode deprecated_mode)
|
||||
DeprecatedResult Client::try_request_file_deprecated(GUI::Window* parent_window, DeprecatedString const& path, Core::OpenMode deprecated_mode)
|
||||
{
|
||||
auto const id = get_new_id();
|
||||
m_promises.set(id, PromiseAndWindow { { Core::Promise<DeprecatedResult>::construct() }, parent_window });
|
||||
|
@ -96,7 +96,7 @@ DeprecatedResult Client::try_request_file(GUI::Window* parent_window, Deprecated
|
|||
return handle_promise<DeprecatedResult>(id);
|
||||
}
|
||||
|
||||
DeprecatedResult Client::try_open_file(GUI::Window* parent_window, DeprecatedString const& window_title, StringView path, Core::OpenMode deprecated_requested_access)
|
||||
DeprecatedResult Client::try_open_file_deprecated(GUI::Window* parent_window, DeprecatedString const& window_title, StringView path, Core::OpenMode deprecated_requested_access)
|
||||
{
|
||||
auto const id = get_new_id();
|
||||
m_promises.set(id, PromiseAndWindow { { Core::Promise<DeprecatedResult>::construct() }, parent_window });
|
||||
|
|
|
@ -27,9 +27,9 @@ class Client final
|
|||
IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/filesystemaccess"sv)
|
||||
|
||||
public:
|
||||
DeprecatedResult try_request_file_read_only_approved(GUI::Window* parent_window, DeprecatedString const& path);
|
||||
DeprecatedResult try_request_file(GUI::Window* parent_window, DeprecatedString const& path, Core::OpenMode mode);
|
||||
DeprecatedResult try_open_file(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::OpenMode requested_access = Core::OpenMode::ReadOnly);
|
||||
DeprecatedResult try_request_file_read_only_approved_deprecated(GUI::Window* parent_window, DeprecatedString const& path);
|
||||
DeprecatedResult try_request_file_deprecated(GUI::Window* parent_window, DeprecatedString const& path, Core::OpenMode mode);
|
||||
DeprecatedResult try_open_file_deprecated(GUI::Window* parent_window, DeprecatedString const& window_title = {}, StringView path = Core::StandardPaths::home_directory(), Core::OpenMode requested_access = Core::OpenMode::ReadOnly);
|
||||
DeprecatedResult try_save_file_deprecated(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::OpenMode requested_access = Core::OpenMode::WriteOnly | Core::OpenMode::Truncate);
|
||||
|
||||
Result save_file(GUI::Window* parent_window, DeprecatedString const& name, DeprecatedString const ext, Core::Stream::OpenMode requested_access = Core::Stream::OpenMode::Write | Core::Stream::OpenMode::Truncate);
|
||||
|
|
|
@ -522,7 +522,7 @@ Gfx::IntRect OutOfProcessWebView::notify_server_did_request_fullscreen_window()
|
|||
|
||||
void OutOfProcessWebView::notify_server_did_request_file(Badge<WebContentClient>, DeprecatedString const& path, i32 request_id)
|
||||
{
|
||||
auto file = FileSystemAccessClient::Client::the().try_request_file_read_only_approved(window(), path);
|
||||
auto file = FileSystemAccessClient::Client::the().try_request_file_read_only_approved_deprecated(window(), path);
|
||||
if (file.is_error())
|
||||
client().async_handle_file_return(file.error().code(), {}, request_id);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue