Commit Graph

9190 Commits

Author SHA1 Message Date
Sebastian Dröge
bdd51aa8ca Mark return value of g_dbus_interface_get_info() as nullable
`GDBusProxy` implements this interface but allows construction with a
`NULL` interface info and also marks its getter/setter for the interface
info accordingly.

Callers of `g_dbus_interface_get_info()` need to assume that it can
return `NULL` unless they constructed the `GDBusInterface` in a way that
guarantees that the interface info is available.
2025-10-20 20:47:38 +00:00
Philip Withnall
bbc508b78f gnetworkmonitorbase: Add missing notify::connectivity signal
The connectivity is directly derived from the `is_available` variable,
so if that changes, we need to notify of a change in `connectivity` too.

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

Fixes: #3803
2025-10-20 16:15:45 +01:00
Luca Bacci
5a3231dbda GIO/Win32: Remove custom definitions of system interfaces 2025-10-17 10:46:01 +02:00
Marco Trevisan
618d45cc83 Merge branch 'snap-document-portal-launch' into 'main'
GDesktopAppInfo: Use document portal to open all the URIs for snaps

See merge request GNOME/glib!4822
2025-10-17 04:00:20 +02:00
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
bd4b57e811 Merge branch 'scan-build-fixes' into 'main'
Fix various scan-build errors

See merge request GNOME/glib!4866
2025-10-17 03:47:16 +02:00
Philip Withnall
d904f77770 gunixmounts: Silence a scan-build false positive about a file handle leak
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-10-17 00:27:02 +01: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
Philip Withnall
3e1176e4b8 Merge branch 'socket-control-docs' into 'main'
gsocketcontrolmessage: Fix a minor typo in a doc comment

See merge request GNOME/glib!4858
2025-10-16 21:10:46 +00:00
Philip Withnall
0ab1866145 Merge branch '3798-appinfo-portal-crash' into 'main'
gopenuriportal: Fix a crash when the file can’t be opened

Closes #3798

See merge request GNOME/glib!4859
2025-10-16 21:04:12 +00: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
Philip Withnall
21179497cf Merge branch 'zero-terminated-annotations' into 'main'
gio: add some nullable / zero-terminated annotations

See merge request GNOME/glib!4789
2025-10-16 20:10:49 +00: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
François Laignel
7d032f2fde gio: add some nullable / zero-terminated annotations 2025-10-16 19:36:56 +00:00
Philip Withnall
5917bce3de gopenuriportal: Fix a crash when the file can’t be opened
Rather than reporting an error via a new `GTask`, report it via the
`GTask` we’ve already created. This avoids a critical warning about
destroying the `GTask` without returning a result.

Also ensure to disconnect the D-Bus signal subscription first, to avoid
an assertion failure in `call_data_free()`.

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

Fixes: #3798
2025-10-16 20:28:19 +01:00
Philip Withnall
9b03809a16 gsocketcontrolmessage: Fix a minor typo in a doc comment
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-10-16 20:28:01 +01: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