Commit Graph

9178 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
bc35a1496d gio/gdesktopappinfo: Also use document portal for desktop file snaps
When a snap is launched from its non-dbus-activable desktop file we may
still need to use the portal to pass the URIs to the program, so that it
can access to them even if confined.

In fact most snaps are not dbus-activable, but they rely on the classic
desktop file activation.
2025-10-17 03:48:55 +02:00
Marco Trevisan (Treviño)
29fdcec8f3 gio/tests/desktop-app-info: Check child exit status
We need to ensure that the child we launch is not failing otherwise it
won't be possible to catch any assertion failure that it may happen
2025-10-17 01:07:33 +02:00
Marco Trevisan (Treviño)
23c2483703 gio/gdesktopappinfo: Use document portal to open URIs for dbus-started snaps
Snap applications like flatpak apps may need to use the portals to open
files, so use the same logic that we have for flatpaks but using the
snap ID that matches portal expectations
2025-10-16 22:12:00 +02:00
Marco Trevisan (Treviño)
85ec0256fe gio/tests/dbus-appinfo: Ensure that a dbus application has been opened
We were checking the results of opening an sandboxed application, but
never if the open was actually invoked.

So if another desktop file was used in tests, we were never getting any
failure, at least not related to the lack of a file being opened
2025-10-16 22:10:14 +02:00
Marco Trevisan (Treviño)
3159c3f806 dbus-appinfo: Generalize the flatpak appplication as a sandboxed app
So that we can use it for both flatpaks and snaps
2025-10-16 22:05:27 +02:00
Marco Trevisan (Treviño)
b3a7c087ee gio/tests/gapplication: Check the values received on action activation
As per commit 0144feb41 the activate action paramter may pack multiple
values but while the behavior was checked we did not check the content
of the values we were receiving in the action callback.

So, also ensure that the variant values we receive are matching the
expectations.
2025-10-16 19:16:26 +00:00
Marco Trevisan (Treviño)
085deb7697 gio/tests/documentportal: Add tests covering portal failures
In case the portal fails to create what we expect, or we can't read the
files we should fail. Add test cases for this too.
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
fb0ee7562b gio/gdocumentportal: Get portal file name by listing the mount point
Instead of guessing the portal file name by using the original file name
let's just inspect the portal document ID directory and get the actual
file name
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
a3b99ce554 gio/tests/fake-document-portal: Really create fake files
In order to properly test the document portal, let's also create some
dummy files that are named after the FDs we receive and using the
document-id path as the real portal does
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
eb78cfeeca gio/tests/fake-document-portal: Test that the app-id matches the request
Ensure that the app-id requiring the document matches the one we want,
so that we can actually test the code in GDesktopAppInfo that does the
mapping
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
3eb2abb406 fake-document-portal: Fix signature of function callback
We were missing a parameter, as per the generated bindings
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
352cfe600a gio/gdocumentportal: Use the target name when opening a symlink
When an URI to a symlink is added to the portal, we open it and we send
the FD (of the target) to the portal. This one has no clue about the original
symlink and so it mounts a file that is named like the target.

g_document_portal_add_documents(), however returns a path that contains
the original name and that one is what is sent to the applications when
used via GDesktopAppInfo.

Basically, this is the situation:
  - /tmp/symlink -> /tmp/target
  - An application is launched to open file:/tmp/symlink
  - The portal creates file:/$XDG_RUNTIME_DIR/doc/ID/target
  - Gio converts the path to file:/$XDG_RUNTIME_DIR/doc/ID/symlink

Now, since we can't just pass the symlink to the portal without also
changing the logic there, it's just better to do the conversion ourself,
and so, we use the already-opened fd to figure out the real path of the
opened file, and we return a document file URI that uses the target
basename instead
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
d81701de56 gio/tests: Add document portal tests
While this can be tested using desktop apps, adding some unit tests
makes simpler to verify the edge cases
2025-10-16 20:29:32 +02:00
Marco Trevisan (Treviño)
ddc324da03 gio/tests/fake-document-portal: Use a sequential ID for docs
It makes things clearer to test
2025-10-16 20:29:32 +02:00
Luca Bacci
b623031e22 glib-compile-resources: print error message when the temp file cannot be created 2025-10-16 13:16:58 +00:00
FeRD (Frank Dana)
9e049b9008 Entity tags: Link to RFC9110 for HTTP ETag reference
The RFC9110 explanation of HTTP ETags is far superior to
the disjoint ramblings found in (now-obsoleted) RFC2616,
and serves as a much better reference for comparison
with GFile entiity tags. Also, link directly to relevant section.
2025-10-02 11:06:41 +00:00
Philip Withnall
5b88afa767 Merge branch 'keep-suffix-name-when-trashing' into 'main'
GLocalFile: keep suffix name when trashing

See merge request GNOME/glib!4838
2025-09-30 16:00:01 +00:00
Philip Withnall
b7d8d88931 Merge branch 'file-equal-docs' into 'main'
gfile: Expand documentation around file equality

See merge request GNOME/glib!4815
2025-09-30 15:29:59 +00:00
wangrong
05012cd1c4 GLocalFile: keep suffix name when trashing
Keeping the suffix name makes it easier to get the correct content-type.
2025-09-26 14:34:16 +08:00
Marco Trevisan
ed36f4c642 Merge branch 'wip/suppress-missing-lock-coverity' into 'main'
gdbus-codegen: Supress coverity warning in skeleton finalization

See merge request GNOME/glib!4825
2025-09-21 13:35:26 +02:00
Carlos Garnacho
592082ef1d gdbus-codegen: Supress coverity warning in skeleton finalization
This commit has the potential to close a thousand Coverity issues.
On generated code from gdbus-codegen, Coverity typically warns on
skeleton->priv->changed_properties_idle_source happening outside
the skeleketon->priv->lock during finalize(), while it's protected
by this mutex in other parts.

Presumably if the object is in finalization, there should be no
other threads poking at it, so the code is actually safe for the
intended use and the warning moot.

To address this, change gdbus-codegen to prefer g_clear_pointer()
with glib >= 2.38 (should be most often the case nowadays) so this
access is reserved to a single line of code, and mark this line of
code with a Coverity code annotation in order to suppress the
warning.
2025-09-21 12:02:58 +02:00
Simon McVittie
67dc482f8a gio/tests: Wait up to 10 seconds for a signal to be received
If the build/test machine is slow, heavily-loaded or otherwise
inconvenienced, it might take a few seconds for the signal to be sent
by the subprocess, received by the message bus, re-broadcasted by the
message bus and received by the test code. Wait a few more seconds
before giving up.

If this test is successful, increasing this timeout will not slow it
down: we stop waiting for the signal as soon as we receive it. This will
only make any difference if the test would have failed.

Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:37 +01:00
Simon McVittie
73224802b3 gio/tests: Convert the time to wait for expected signal into a constant
No functional change.

Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:30 +01:00
Simon McVittie
0960e72b07 gio/tests: Avoid a race condition
We have two things happening in parallel:

1. The GDBus worker thread writes out an AddMatch call to the socket,
   the message bus reads that method call from the other end of the
   socket, and the message bus responds by adding the match rule
   for the signal subscription

2. The main thread forks, and the child execs
   gdbus-connection-flush-helper, which sends the signal that we are
   expecting; the message bus receives that signal, and broadcasts it
   to subscribers, if any

Normally (1.) wins the race because exec'ing a child process is more
time-consuming than IPC, and the test passes.

However, it is possible for (2.) to win the race. If so, we will never
receive the expected signal (because it was received by the message bus
before the AddMatch() method call, so at the time it was received, the
test was not yet a subscriber); the test waits until the timeout and
then gives up, and the test fails.

For whatever reason, Debian's s390x buildd seems to be reliably failing
this test since this week, having previously passed. I don't know what
changed. I can (very rarely) reproduce the race condition described
above on a developer-accessible s390x machine by repeatedly running the
/gdbus/connection/flush test in a loop.

Bug-Debian: https://bugs.debian.org/1115617
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:23 +01:00
Simon McVittie
ac7275b185 gio/tests: Factor out connection_wait_for_bus() from gdbus-subscribe
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-09-19 13:44:05 +01:00
Lukáš Tyrychtr
4ab0357974 gio-tool-trash: Report error when emptying the trash
This adds error reporting and proper exit code when emptying the trash fails
for some (mainly permission) related error.

Fixes #3785.
2025-09-18 15:11:47 +00:00
Philip Withnall
b961111c97 gfile: Expand documentation around file equality
Prompted by
https://discourse.gnome.org/t/help-on-g-file-equal-and-g-file-attribute-id-file/31268/5.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-09-17 10:51:31 +01:00
Philip Withnall
a8b9c237cf Merge branch 'gdbus-register-error-domain-out-annotation' into 'main'
GDBus: Add `(out)` annotation to quark in g_dbus_error_register_error_domain()

See merge request GNOME/glib!4798
2025-09-16 14:20:58 +00:00
Philip Withnall
3691e4d3d7 Merge branch 'win32-app-info-co-allow-set-foreground-window' into 'main'
GWin32AppInfo: Allow focus-stealing when requested via GAppLaunchContext

See merge request GNOME/glib!4759
2025-09-16 14:19:21 +00:00
Philip Withnall
3d0c3bfae8 Merge branch '3771-keyfile-invalid-escapes' into 'main'
gdesktopappinfo: Error out on more invalid desktop files

Closes #3771

See merge request GNOME/glib!4766
2025-09-16 14:18:58 +00:00
Uwe Korn
2b0f5304bd gio/tests/socket-listener should depend on libdl 2025-09-11 16:04:15 +00:00
Sebastian Dröge
58791ea699 GDBus: Add (out) annotation to quark in g_dbus_error_register_error_domain() 2025-09-11 14:01:27 +03:00
Tobias Stoeckmann
c546ac20d8 tests: Fix clang compilation warnings
With these adjustments, building with clang leads to no warnings:

- The "{ NULL }" statement could be replaced with "{ 0 }" to satisfy
  clang, but this way it's explicitly filling all fields
- Even though "i" is not read with these g_array_binary_search calls,
  it rightfully should be set
2025-09-05 22:34:44 +02:00
Tobias Stoeckmann
48bf508bc1 docs: Fix typos
Typos found with codespell
2025-09-03 21:47:11 +02:00
Tobias Stoeckmann
3d21160b85 docs: Fix typos in comments 2025-09-03 21:33:53 +02:00
Luca Bacci
fc9ce24359 GWin32AppInfo: Add support for focus stealing (unpackaged apps)
...by calling AllowSetForegroundWindow.

See previous commit for more informations.
2025-09-03 17:05:48 +02:00
Luca Bacci
29535c8998 GWin32AppInfo: Add support for focus stealing (packaged apps)
IApplicationActivationManager implements the IForegroundTransfer interface,
which lets us specify if the launched app is allowed to create a window
that steals focus (assuming our process has such ability). By default that
setting is disabled, so launched apps appear in the background and do not
get focus.

See XDG activation (Wayland) and the Startup notification specification (X11)
for equivalent functionality on Unix.

Support for focus-stealing can be set in GAppLaunchContext subclasses like
GdkAppLaunchContext, see gdk_app_launch_context_set_timestamp [1].

[1] https://docs.gtk.org/gdk4/method.AppLaunchContext.set_timestamp.html
2025-09-03 17:05:48 +02:00
Luca Bacci
8168e68716 GWin32AppInfo: Add support for startup-notification-id
GdkAppLaunchContext for Wayland / X11 fetch an opaque token
from the compositor.

On Windows, the system doesn't give you any token. Instead,
the token is implicit, and you can pass that to other
processes via dedicated APIs like AllowSetForegroundWindow.

Due to that, we use an internal format for startup-notify-id
that lets us check what to pass to activated apps.
2025-09-03 17:05:32 +02:00
Philip Withnall
5c42d4f82c gdesktopappinfo: Error out on more invalid desktop files
Currently, the `GDesktopAppInfo` constructors return an error if
validity checks for the `Exec=` line, or other lines, fail. However,
they were ignoring the validity checks done at the `GKeyFile` level, for
invalid UTF-8 or string escaping.

It seems consistent to error out for those too, rather than pretending
that the key file line wasn’t set at all (i.e. treating it like `NULL`).

Spotted by Daniel Kondor.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3771
2025-09-02 17:50:49 +01:00
Niveditha Rau
f607ae6511 glocalfile: Disable faccessat()-based query_exists on Solaris 2025-09-01 13:56:21 -07:00
Kleis Auke Wolthuizen
e506d16efa gio: gmemorymonitorpsi: Replace GRegex with g_str_has_prefix()
Using g_str_has_prefix() and simple pointer arithmetic is easier and
more efficient.

No functional change.
2025-08-30 13:31:38 +00:00
Emmanuele Bassi
e13fe685cf docs: Fix links to GioUnix types
Now that Unix-specific types have been moved to the GioUnix, we need to
fix the various links in our documentation.
2025-08-29 18:00:50 +01:00
Zhou Qiankang
9c1226223c tests/gio: skip Unix socket-mock tests on Windows
Signed-off-by: Zhou Qiankang <wszqkzqk@qq.com>
2025-08-19 21:31:13 +08:00
Rafael Girão
ce3a5dbbbe glib: respect symlinks when updating mimeapps.list
In the case where mimeapps.list is a symlink, gio-issued updates would
overwrite the file, destroying the symlink in the process.

Instead, this approach recursively follows mimeapps.list symlinks
and overwites the contents of the final file instead.

Closes #3579
2025-08-18 13:44:23 +00:00
Philip Withnall
30aff12d89 gmemorymonitorpoll: Hold a weak ref from a source callback to the monitor
It’s possible for the dispatch of the timeout source to race with the
finalisation of the `GMemoryMonitorPoll`, given that the timeout is run
in the GLib worker thread.

Protect against that by holding a thread-safe weak ref on the
`GMemoryMonitor` in the callback data.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3758
2025-08-12 13:24:52 +01:00
Niveditha Rau
365c5bcfd1 Disable GMemoryMonitorPsi on Solaris
PSI doesn’t exist in the Solaris kernel, so this `GMemoryMonitor`
implementation can never be chosen at runtime on Solaris.
2025-08-12 08:31:04 +00:00
Tobias Stoeckmann
b8f9743a4d systemtap: Use correct formatters/types
Try to avoid casting variables to potentially smaller types to fit
defined probes. This can truncate values and lead to wrong results.

Also make sure that signedness matches.

Since GType can be even 128 bit on CHERI architecture, cast all these
various types used based on platform to uintmax_t which SystemTap
properly processes.
2025-08-08 23:15:38 +02:00
Antoine Jacoutot
ff47c01818 glocalfile: Disable faccessat()-based query_exists on OpenBSD 2025-08-07 11:28:25 +00:00
Khalid Abu Shawarib
7a38cbc1dc gio/filenamecompleter: Use platform-specific directory separator 2025-08-05 17:36:41 +03:00
Khalid Abu Shawarib
48f8812cca gio/tests/filenamecompleter: Add a basic test 2025-08-05 17:36:00 +03:00