Commit Graph

46 Commits

Author SHA1 Message Date
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Ali Mohammad Pur
aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
Karol Kosek
27011cf55d LibFSAC+Userland: Pass options for FSAC::open_file() using a struct
It was rather inconvenient having to specify all arguments if you wanted
to modify only the last one.
2023-06-11 09:40:17 +01:00
thankyouverycool
9ecfacaffd LibFileSystemAccessClient: Don't crash when formatting error messages
Since c140b67 ESUCCESS Errors aren't allowed. FSAC was initializing
an ErrorOr<String> arbitrarily to 0 for scope, causing it to hit the
VERIFY().
2023-06-09 19:46:44 +01:00
Ben Wiederhake
8df7b42078 FileSystemAccessServer: Don't transmit unused data
The server cannot use these values anywhere, because this method always
sets 'prompt = ShouldPrompt::No'. This saves a bunch of roundtrips for
all clients that use FSAS to read abritrary files.
2023-05-29 13:17:22 +02:00
thankyouverycool
37e621a3c7 LibFileSystemAccessClient: Improve error propagation
Previously FSAC displayed some but not all errors and always
rejected directories and devices. This has led most apps to ignore
response errors in open/save actions or show redundant messages.

Now FSAC displays all errors including fd failures and has the ability
to silence messages for directories, devices and ENOENT, which some
apps handle differently. Silenced directory and device errors now
return files on success.

A request's access mode is now stored in RequestData to format more
accurate error messages from the user's perspective.

Resolved promises don't require callback propagation so they're voided
2023-05-19 06:20:41 +02:00
Lucas CHOLLET
5a4c61838f FileSystemAccessServer: Use ECANCELED instead of -1
-1 was used when the user cancel the dialog, `ECANCELED` is a bit more
explicit about what it is.
2023-05-05 15:12:24 +01:00
Cameron Youell
c048cf2004 Libraries: Convert DeprecatedFile usages to LibFileSystem 2023-03-24 10:58:43 +00:00
huttongrabiel
6a5c561a41 FileSystemAccessServer: Implement FileTypeFilter to open_file()
This is the same functionality as in FilePicker. It allows the
specification of what file types are allowed.
2023-03-22 22:33:19 +00:00
Lucas CHOLLET
832478ad0c LibFileSystemAccessClient: Don't make illegal operation on files
`handle_prompt_end` is calling `is_device` and `is_directory` on the
path chosen by the user. However, this path is not necessarily unveiled.
Meaning that it the both functions results in an illegal operation.

This is a regression introduced with the usage of LibFileSystem in
1d24f394. This patch, revert the behavior at its previous state, i.e.
calling both functions with the fd provided by the FSAS.
2023-03-22 09:06:38 +01:00
Cameron Youell
1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
kleines Filmröllchen
8f4d0d3797 LibCore+Userland: Make Promise's on_resolve fallible
This will be primarily necessary for BackgroundAction integration, but
it already allows us to add proper error handling in LibIMAP :^)
2023-03-13 12:12:17 +00:00
kleines Filmröllchen
bfd9f681f7 LibCore+Userland: Allow canceling promises
To make EventLoop cancel its managed Promises, we need the ability to
cancel them in the first place.
2023-03-13 12:12:17 +00:00
Lucas CHOLLET
e8249d735d LibFileSystemAccessClient: Remove the deprecated API
Concerned functions are:
 - try_request_file_read_only_approved_deprecated
 - try_request_file_deprecated
 - try_open_file_deprecated
 - try_save_file_deprecated

It also allows some simplifications in the implementation of the client.
2023-02-16 20:11:52 +01:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
a96339b72b LibCore: Move Stream-based sockets into the Core namespace 2023-02-13 00:50:07 +00:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Karol Kosek
86f6586c6e LibFileSystemAccessClient: Add functions returning FSAC::File
This patch reimplements the now deprecated try_open_file(),
try_request_file() and try_request_file_read_only_approved() functions,
with the difference that the new ones return a FSAC::File object
(currently a wrapper with a Core::Stream and a filename) instead of a
Core::File.

Implemented in a similar manner to 6dd716adf2.
2023-01-07 10:53:43 +00:00
Karol Kosek
2cbe2dd3c0 LibFileSystemAccessClient+CrashReporter: Introduce FSAC::File and use it
The new result returned just a file stream, which wasn't sufficient
enough for most applications because it didn't provide a filename.

This patch will make a new File object that has both a file stream and
a filename.
2023-01-07 10:53:43 +00:00
Karol Kosek
247db3fdd0 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. :^)
2023-01-07 10:53:43 +00:00
Lucas CHOLLET
c0bc3b9814 FileSystemAccessServer: Use Core::Stream
This patch also updates corresponding functions from
`LibFileSystemAccessServerClient`.

From the FileSystemAccessClient point of view, it only makes the server
take `Core::Stream::OpenMode` instead of `Core::OpenMode`. So, `enum`
conversions only happen within deprecated functions and not in the new
`Core::Stream` friendly API.

On the server side, it just removes two usages of `Core::File::open()`.
2023-01-06 14:52:29 +00:00
Lucas CHOLLET
6dd716adf2 LibFileSystemAccessClient: Add save_file()
This method replaces `try_save_file_deprecated()`, as it has the same
behavior but returns a `Core::Stream::File` instead.
2022-12-14 18:26:25 +00:00
Lucas CHOLLET
9ae97c8cb1 LibFileSystemAccessClient: Rename try_save_file =>
`try_save_file_deprecated`

This precedes the addition of a new api using `Core::Stream`
2022-12-14 18:26:25 +00:00
Lucas CHOLLET
c71fc0683f LibFileSystemAccessClient: Rename Result => DeprecatedResult
This precedes the addition of a new `Result`, using `Core::Stream::File`
instead `Core::File`.
2022-12-14 18:26:25 +00:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Timothy Flynn
4fd9e3ab08 Userland: Remove workarounds for LibIPC include order sensitivity 2022-11-15 13:25:51 -05:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Peter Elliott
7af5eef0dd SystemServer+LoginServer+Userland: Switch to sid-based sockets
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
2022-10-03 11:11:29 +02:00
Lucas CHOLLET
e8115bfdb1 Base: Launch FileSystemAccessServer at session start-up 2022-08-14 21:52:35 +01:00
Lucas CHOLLET
1b36348d8b LibCore+LibIPC: Recognise %uid in path
This patch allows to insert "%uid" in `IPC_CLIENT_CONNECTION`
declaration and in SystemServer's ini files. This pattern is replaced
then replaced by the UID of the owner of the service. It opens a path
for seamlessly managed, per-user portal.
2022-08-14 21:52:35 +01:00
sin-ack
e5f09ea170 Everywhere: Split Error::from_string_literal and Error::from_string_view
Error::from_string_literal now takes direct char const*s, while
Error::from_string_view does what Error::from_string_literal used to do:
taking StringViews. This change will remove the need to insert `sv`
after error strings when returning string literal errors once
StringView(char const*) is removed.

No functional changes.
2022-07-12 23:11:35 +02:00
MacDue
5b9d7bb335 FileSystemAccessServer: Call window stealing functions sync
These functions were changed to synchronous in #13870 but
the async_ versions were still being called. This led to
frequent crashes when loading local files in Browser.
2022-06-30 11:15:24 +01:00
Lucas CHOLLET
deb525fd9d LibFileSystemAccessClient: Return an errno instead of a string literal
Returning an errno to ease error transmission over IPC.
2022-06-27 20:22:15 +01:00
Lucas CHOLLET
9521952f36 FileSystemAccessServer: Manage concurrent file requests
Before this patch, when you called FileSystemAccessServer::Client::try_*
twice, the second call used the same variable to store the promise. This
"race condition" is now solved using a HashMap, to store multiple
parallel requests.
2022-06-27 20:22:15 +01:00
Itamar
935d023967 Userland: Rename WindowServerConnection=>ConnectionToWindowServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Itamar
d88da82e28 Userland: Rename IPC::ServerConnection=>IPC::ConnectionToServer
This was done with CLion's automatic rename feature.
2022-02-25 22:35:12 +01:00
Mustafa Quraish
ee74aafdca FileSystemAccessClient: Remove old API returning file descriptors :^)
Since all users of the old API are now removed, this commit removes all
the methods that returned raw file descriptors, in favor of returning
`ErrorOr<NonnullRefPtr<Core::File>`.
2022-01-20 10:39:12 +01:00
Mustafa Quraish
0c98e553e8 FileSystemAccessClient: Add try_* variants returning Core::File
The current implementation is a bit of a hack since we also want to keep
around the previous variants for now, but will be cleaned up later once
all applications have been ported to the new API.
2022-01-20 10:39:12 +01:00
sin-ack
2e1bbcb0fa LibCore+LibIPC+Everywhere: Return Stream::LocalSocket from LocalServer
This change unfortunately cannot be atomically made without a single
commit changing everything.

Most of the important changes are in LibIPC/Connection.cpp,
LibIPC/ServerConnection.cpp and LibCore/LocalServer.cpp.

The notable changes are:
- IPCCompiler now generates the decode and decode_message functions such
  that they take a Core::Stream::LocalSocket instead of the socket fd.
- IPC::Decoder now uses the receive_fd method of LocalSocket instead of
  doing system calls directly on the fd.
- IPC::ConnectionBase and related classes now use the Stream API
  functions.
- IPC::ServerConnection no longer constructs the socket itself; instead,
  a convenience macro, IPC_CLIENT_CONNECTION, is used in place of
  C_OBJECT and will generate a static try_create factory function for
  the ServerConnection subclass. The subclass is now responsible for
  passing the socket constructed in this function to its
  ServerConnection base; the socket is passed as the first argument to
  the constructor (as a NonnullOwnPtr<Core::Stream::LocalServer>) before
  any other arguments.
- The functionality regarding taking over sockets from SystemServer has
  been moved to LibIPC/SystemServerTakeover.cpp. The Core::LocalSocket
  implementation of this functionality hasn't been deleted due to my
  intention of removing this class in the near future and to reduce
  noise on this (already quite noisy) PR.
2022-01-15 13:29:48 +03:30
Arne Elster
60c3ad9ae8 LibFileSystemAccessClient: Allow custom access rights for open/save
There can be cases when one wants to open a file not just for reading
but also for writing. It was already possible to have a custom open mode
for request_file, now it is also possible through the open/save dialogs.
2021-12-23 23:25:47 -08:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Mustafa Quraish
ecb3f882a3 LibFileSystemAccessClient: Convert request paths to absolute if needed
FileSystemAccessServer requires all paths to be absolute, and will
just crash if this is not the case. Instead of expecting the user to
always provide an absolute path, the client just checks to see if
the path provided was absolute, and if not makes a request with the
absolute path instead.
2021-09-10 20:46:50 +04:30
Mustafa Quraish
2a968e92f0 FileSystemAccessServer: Allow read-only access without prompting
This commit adds a new request to the FileSystemAccessServer
endpoint, allowing the clients to get read-only access to a file
without getting a Dialog-box prompting the user for access.

This is only meant to be used in cases where the user has asked
specifically to open a file through the command-line arguments.
In those cases, I believe it makes sense for the read-only access
to be implicit. Always prompting the user gets a bit annoying,
especially if you just quickly want to open a file through the CLI.

The new request name has been made extremely specific to make sure
that it's only used when appropriate.
2021-09-10 20:46:50 +04:30
Timothy
95ee7069d5 FileSystemAccessServer: Add window title as parameter for opening file 2021-08-07 12:48:22 +02:00
Timothy
215f383b12 LibFileSystemAccessClient: Use WindowServer window stealing interface 2021-07-18 17:21:28 +02:00
Timothy
38594dde79 FileSystemAccessServer+TextEditor: Implement cross-process modal prompts
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.
2021-07-18 17:21:28 +02:00