Commit Graph

8862 Commits

Author SHA1 Message Date
Philip Withnall
c5e17bc37f Merge branch 'amolenaar/macos-launch-uris-async' into 'main'
macos: Implement GAppInfo launch_uris_async interface

Closes #3403

See merge request GNOME/glib!4129
2024-08-14 13:16:06 +00:00
Luke T. Shumaker
03a2ec8fee docs: g_socket_{get,set}_option: Fix the link to gnetworking.h 2024-08-13 15:19:21 -06:00
Luke T. Shumaker
e4a2aa8f39 docs: Wrap things that gi-docgen mistakes as HTML tags in backticks
This are nasty, because they mean words get dropped from the
documentation.  This can be seen at

 - https://docs.gtk.org/gio/ctor.DBusNodeInfo.new_for_xml.html where
   it reads "one top-level element" instead of "one top-level <node>
   element".

 - https://docs.gtk.org/gio/method.ProxyResolver.lookup.html where it
   reads "where could be" instead of "where <protocol> could be".

 - https://docs.gtk.org/gio/method.Socket.get_option.html where it
   reads "[][gio-gnetworking.h]" instead of
   "[<gio/gnetworking.h>][gio-gnetworking.h" (also, this markdown link
   needs fixed, but let's save that for another commit).

 - https://docs.gtk.org/glib/ctor.DateTime.new_from_iso8601.html where
   the text is incomprehensible; "strings of the form are supported"
   instead of "strings of the form <date><sep><time><tz> are
   supported"; further references to <sep>, <date>, <time>, and <tz>
   are similarly mangled.

 - https://docs.gtk.org/glib/method.MatchInfo.fetch_named.html and
   https://docs.gtk.org/glib/method.MatchInfo.fetch_named_pos.html
   where the regex reads as "(?Pa)?b" instead of as "(?P<X>a)?b",
   changing the meaning of it.

 - https://docs.gtk.org/glib/method.Regex.match_all_full.html is all
   wack because the "<a>" in the example string is taken to be an HTML
   link; and all example strings and regexes are mangled (also, one of
   the regexes has a stray ";" in it, but let's save that for another
   commit).

 - https://docs.gtk.org/glib/method.Regex.replace.html where it simply
   reads "\g" instead of "\g<number>" and "\g<name>".

Fix those.
2024-08-13 15:19:21 -06:00
Luke T. Shumaker
d0b59da656 docs: Transition remaining DocBook XML to markdown/HTML
These remaining DocBook tags are mostly harmless; they are passed as
HTML5 tags to the browser, which effectively treats them as just
<span> elements, so all this mistake is doing is dropping some
styling.

This lack of of styling can be seen at:

 - https://docs.gtk.org/gio/enum.DriveStartStopType.html "ATA SECURITY
   UNLOCK DEVICE" is not indicated to be a quote or anything.

 - https://docs.gtk.org/gio/struct.UnixMountEntry.html "/media/cdrom"
   is not rendered in monospace.

 - https://docs.gtk.org/gio/struct.UnixMountPoint.html "/dev" is not
   rendered in monospace.

 - https://docs.gtk.org/glib/type_func.Thread.init.html the notes are
   not indicated to be anything other than regular paragraphs.

Fix that.
2024-08-13 15:19:14 -06:00
Arjan Molenaar
2ad61ed0ee Fix formatting issues 2024-08-10 19:42:32 +02:00
Arjan Molenaar
d23c781e7b macos: Tune launch results for CI
It looks like we have no Finder running.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
1053c016d9 macos: Add test case for invalid scheme
You may not always know which schemes are available.

The library should not bail out, but only show
an informal message. It's the responsibility of
the application to deal with invalid URI schemes.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
fac8a8c8d8 macos: Add test for async launcher
The test brings a Finder window to the front. It's not ideal,
but I have no better idea at the moment. It would be cool if we
can make the test case register itself as handler for a particular
uri scheme, but I have no idea how to do that.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
edd36a907b macos: simplify urlspec setup for launch_uris_async
NB. Using toll-free bridging to cast NSURL to a CFURLRef
See https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/Toll-FreeBridgin/Toll-FreeBridgin.html
2024-08-10 19:34:29 +02:00
Arjan Molenaar
9f0ff882c1 macos: Fill appUrl directly
No need to convert it to a char* first.
This also avoids threading issues with OsxAppInfo's get_filename() method.
2024-08-10 19:34:29 +02:00
Arjan Molenaar
71e87fc29c more indentation fixes 2024-08-10 19:34:29 +02:00
Arjan Molenaar
e9ee147ac9 macos: fix header indentation 2024-08-10 19:34:29 +02:00
Arjan Molenaar
c67ae98588 macos: Implement GAppInfo.launch_uris_async interface
The implementation is heavily inspired by the Windows implementation.
2024-08-10 19:34:29 +02:00
Emmanuele Bassi
c865680f96 Merge branch 'fix-up-gapplication-docs-a-little' into 'main'
docs: Linkify a function

See merge request GNOME/glib!4181
2024-08-05 12:55:32 +00:00
Matthias Clasen
653cdb73d7 docs: Linkify a function
I answered a question on irc about withdrawing notifications, and
when I handed out a link to the GApplication docs, I noticed we
don't have this function name linkified. Fix that.
2024-08-05 08:23:45 -04:00
Marco Trevisan (Treviño)
6c679fb37a gcancellable: Mark assert-only variable as unused 2024-08-02 13:57:29 +02:00
Julian Sparber
23b858a3de gappinfo: Pass activation token from launch context to open_uri/file portal
The `activation_token` option was added to the portal in v4, so let's
actually pass a activation token if we have one.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2868
2024-07-29 09:30:09 +02:00
Julian Sparber
6210708f05 gappinfo: Allow giving no GAppInfo for getting startup notify id
On Wayland the activation token returned by
`g_app_launch_context_get_startup_notify_id()` doesn't depend on the
`GAppInfo`. The token is only used to hand over focus to the
application that is launched. In some cases it's not even possible to know
what application will actually be used to open the files. For example
when using portals within a sandbox. Therefore, allow providing no
`GAppInfo`.

This also makes clear in the docs that the `files` argument can be `NULL`.
2024-07-29 09:30:09 +02:00
Julian Sparber
6ee0389f68 gopenuriportal: Rename functions and switch to GFile as argument
We want to add the support for the activation token, to get it we use
`g_app_launch_context_get_startup_notify_id` which takes a list of
files, so that we don't have to create a GFile twice simply change the
signature of the functions. Fortunately this isn't a public API.
2024-07-29 09:30:09 +02:00
Roshan-R
c534037e12 meson: Fix project not compiling in macOS
Fixes: #3419
2024-07-28 19:50:30 +05:30
Nirbheek Chauhan
a4483644e8 meson: Fix another kqueue build race on macOS
`gobject-visibility.h` is also needed at build time. To reproduce the
error, just run `ninja gio/kqueue/libkqueue.a`
2024-07-27 08:03:42 +05:30
Philip Withnall
460d284fce
gcontenttype: Add platform-independent top level API file
This file doesn’t contain any real implementation, it just call the
`impl` functions from the platform-specific files
`gcontenttype-{fdo,osx,win32}.[cm]`.

It serves as a location for the doc comments, introspection annotations
and API preconditions, and will be built on every platform. In
particular, this means that we get consistent GIR output for the
`g_content_type_*()` APIs regardless of whether GLib was built on Linux or
Windows or macOS.

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

Helps: #3399
2024-07-24 17:46:31 +02:00
Philip Withnall
7bec6327a2
gio: Rename gcontenttype.c to gcontenttype-fdo.c
This reflects its status as actually platform-dependent: it’s only built
on systems using the freedesktop.org content type system.

It makes the file naming match up with other platform-specific
implementations, such as `gcontenttype-win32.c` and
`gcontenttype-osx.m`.

A subsequent commit will introduce a platform-independent high level API
wrapper so that the introspection annotations from this file can be
reused between platforms.

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

Helps: #3399
2024-07-24 17:46:25 +02:00
Philip Withnall
bf630dd4fd
gio: Rename gosxcontenttype.m to gcontenttype-osx.m
To make it consistent with the other platform-specific content type
implementations.

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

Helps: #3399
2024-07-24 17:46:19 +02:00
Philip Withnall
21fdb3be24
gappinfo: Move all platform-independent API docs to gappinfo.c
Previously, some of the doc comments for platform-independent APIs were
in `gdesktopappinfo.c`, which is only built on Unix systems. This meant
the introspection annotations for those APIs were not used on non-Unix
systems, which caused platform differences in `Gio-2.0.gir`.

So, move those doc comments to `gappinfo.c` and put them next to some
new platform-independent wrapper functions which provide a consistent
entry point and location for the API preconditions.

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

Helps: #3399
2024-07-24 17:45:22 +02:00
Philip Withnall
d1945c7abb
gdesktopappinfo: Add additional links to the Desktop Entry Spec
Might as well make it easy for people to look up what we’re talking
about.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-24 14:37:18 +02:00
Philip Withnall
c474d4065d
gdesktopappinfo: Port doc comments to gi-docgen syntax
Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3250
2024-07-24 14:23:18 +02:00
Marco Trevisan (Treviño)
54d9c26b34 gcancellable: Reference the object before locking when doing signal emission
On g_cancellable_cancel() we were increasing the GCancellable ref count
before emitting the ::cancelled signal, this is a safe thing to do but
it was happening while the cancellable was locked, and this may have
potentially waken up some toggle notifications.

To prevent this, reference the GCancellable just before locking.
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
3a07b2abd4 GCancellable: Use per-instance mutex logic instead of global critical sections
GCancellable is meant to be used in multi-thread operations but all the
cancellable instances were sharing a single mutex to synchronize them
which can be less optimal when many instances are in place.
Especially when we're doing a lock/unlock dances that may leave another
thread to take the control of a critical section in an unexpected way.

This in fact was leading to some races in GCancellableSources causing
leaks because we were assuming that the "cancelled" callback was always
called before our dispose implementation.

As per this, use per-instance mutexes.

The lock is also now used only to protect the calls that may interact
with cancelled state or that depends on that, as per this we can just
reduce it to the cancel and reset case, other than to the connect one to
prevent the race that we could have when connecting to a cancellable
that is reset from another thread.

We don't really need to release the locks during callbacks now as they
are per instance, and there's really no function that we allowed to call
during a ::cancelled signal callback that may require an unlocked state.
This could been done in case with a recursive lock, that is easy enough
to implement but not really needed for this case.

Fixes: #2309, #2313
2024-07-24 00:21:35 +02:00
Marco Trevisan (Treviño)
0a8cb10f22 gio/tests: Ensure that a GCancellableSource can be used muliple times
Closes: #774
2024-07-24 00:21:35 +02:00
Ondrej Holy
d9fec76b59 gfile: Add support for x-gvfs-trash mount option
Currently, the trash functionality is disabled for system internal mounts.
That might be a problem in some cases. The `x-gvfs-notrash` mount option
allows disabling the trash functionality for certain mounts. Let's add
support for the `x-gvfs-trash` mount option to allow the opposite.

See: https://issues.redhat.com/browse/RHEL-46828
2024-07-16 07:52:00 +02:00
Georges Basile Stavracas Neto
a84c67da71 gio/appinfo: Directly link GdkAppLaunchContext
We can only use the [class@Foo.Bar] syntax for identifiers under
namespaces included by the current namespace. Naturally, we cannot
include the GDK namespace.

Use a direct link for this instead.
2024-07-11 16:23:06 +01:00
Georges Basile Stavracas Neto
ecc9904996 gio/applaunchcontext: Port docs to gi-docgen
This one is a little more self-contained, even though the class name
doesn't match the file it is in.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
b8db83940b gio/appinfo: Port docs to gi-docgen
Adjust all docs to use the gi-docgen referencing syntax, reindent
some of the comments, and add missing annotations to some async
methods.

The error arguments are not necessary with gi-docgen so they're
removed.

Confusingly enough, the docks for GAppInfo is spread between two
files.
2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
110e76a140 gio/actionmap: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Georges Basile Stavracas Neto
3bd477b454 gio/actiongroupexporter: Port docs to gi-docgen 2024-07-11 15:33:41 +01:00
Michael Catanzaro
4a73fbda8b Merge branch 'wip/pwithnall/resolver-parsing-bsd-fix' into 'main'
tests: Fix compilation of resolver-parsing test on FreeBSD

See merge request GNOME/glib!4152
2024-07-09 23:07:02 +00:00
Philip Withnall
fd2295c545 Merge branch 'port-gfilteroutputstream.c-comments' into 'main'
gfilteroutputstream.c: Port all doc comments to gi-docgen

See merge request GNOME/glib!4145
2024-07-09 22:54:47 +00:00
Philip Withnall
929f2ae06b
tests: Fix compilation of resolver-parsing test on FreeBSD
This fixes commit cdcb179808.

`dn_comp()` is needed to build fake DNS records for most of the tests in
this file. The new ownership test is no exception.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/4058481

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 21:41:03 +01:00
Philip Withnall
ef57fa8a29 Merge branch 'port-gbufferedinputstream.c-comments' into 'main'
gbufferedinputstream: Port all doc comments to gi-docgen

See merge request GNOME/glib!4146
2024-07-09 19:36:55 +00:00
Philip Withnall
fc01879341 Merge branch 'wip/pwithnall/macos-ci-fix' into 'main'
tests: Make an error check less specific in gsocketclient-slow

See merge request GNOME/glib!4149
2024-07-09 19:13:26 +00:00
Sudhanshu Tiwari
2e7e51be56 gbufferedinputstream: Port all doc comments to gi-docgen 2024-07-09 18:21:42 +01:00
Philip Withnall
325a9af5e0 Merge branch 'port-gbufferedoutputstream.c-comments' into 'main'
gbufferedoutputstream.c: Port doc comments to gi-docgen

See merge request GNOME/glib!4148
2024-07-09 17:01:46 +00:00
Philip Withnall
8d0bf4ed39
tests: Make an error check less specific in gsocketclient-slow
On Linux the error will be `G_IO_ERROR_CONNECTION_REFUSED`, but on macOS
it will be `G_IO_ERROR_TIMED_OUT`. Both errors seem reasonable to me, so
let’s not specifically require one of them.

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4104#note_2161451

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-09 17:40:16 +01:00
Sudhanshu Tiwari
c48fd73189 gbufferedoutputstream.c: Port doc comments to gi-docgen 2024-07-09 18:03:03 +05:30
Sudhanshu Tiwari
a8b52cd9d6 gfilteroutputstream.c: Port all doc comments to gi-docgen 2024-07-09 17:30:32 +05:30
Leo Assini
202d345a82 GOsxNetworkMonitor: Add network monitor backend for OS X 2024-07-07 19:36:48 +00:00
Philip Withnall
3993d8db52
codegen: Drop unused import
This should have been dropped in commit
38faeca62e but somehow that didn’t happen
and somehow it wasn’t caught by the CI until afterwards.

Fixes: https://gitlab.gnome.org/GNOME/glib/-/jobs/4049254

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-07-07 13:48:46 +01:00
Philip Withnall
8320085557 Merge branch 'andyholmes/resolver-ownership' into 'main'
gthreadedresolver: ref-sink returned records in lookup_records()

Closes #3393

See merge request GNOME/glib!4110
2024-07-05 06:26:51 +00:00
Andy Holmes
cdcb179808
tests: ensure DNS records are full-reference variants
For each test expected to return valid DNS records, test that the
record variants are not floating references.

Also add an test which checks this explicitly for a simple TXT record.
2024-07-04 17:37:44 -07:00
Benoit Pierre
caf7f8ef49 tests: fix some Windows testsuite failures
Add test dependencies on the 2 spawn helpers required on Windows.
2024-07-04 19:35:47 +00:00
Andy Holmes
da3510575e
gthreadedresolver: ref-sink returned records in lookup_records()
The return value to `lookup_records()` methods is set as `transfer full`
but the code path in `g_resolver_records_from_res_query()` doesn't
sink the GVariant.

Add the `g_variant_ref_sink()` call when prepending the record, so
the list hold a full reference on each records.

closes #3393
2024-07-04 12:06:12 -07:00
Philip Withnall
22d699943d Merge branch 'menu-model-diagram' into 'main'
Docs: Replace Gio.MenuModel diagram with SVG

See merge request GNOME/glib!4140
2024-07-04 11:55:11 +00:00
FeRD (Frank Dana)
f4d944119c Menu model example: Update diagram
- Add licensing tags
- Tweak spacing, colors, line thicknesses
- Create light-mode version
- Use `<picture>` tag to include appropriate version for each media
  color scheme.
2024-07-04 12:13:53 +01:00
FeRD (Frank Dana)
85c8a7c0d8 Docs: Replace Gio.MenuModel diagram with SVG
Recreate the `menu-model.png` diagram in SVG, with box outlines and
connectors recolored from black to white. This will allow the diagram
to show up better in the dark documentation theme.
2024-07-04 12:13:53 +01:00
Ernesto de Gracia Herranz
38faeca62e replace package.version.Version by internal code
This drops the dependency on the Python `packaging` module.

Signed-off-by: Ernesto de Gracia Herranz <ernestodgh@jfrog.com>
2024-07-04 11:04:38 +00:00
Yegor Yefremov
b89dba22cd codegen: resolve pylint import issues
Remove unused imports and reorder other imports so that
the standard ones are coming first.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2024-07-02 12:35:09 +02:00
Philip Withnall
1b41818f50 Merge branch 'port-gasyncresult.c-comments' into 'main'
gasyncresult: Port all doc comments to gi-docgen

See merge request GNOME/glib!4128
2024-07-01 13:44:42 +00:00
Gleb Popov
6daebde9a6 Fix gsocketclient-slow test on FreeBSD
The "port" variable ends up being 0 even after successful g_socket_bind.
Use g_socket_get_local_address() to actually get a correct port number.
2024-06-30 15:37:22 +03:00
Sudhanshu Tiwari
f08952d5fe gasyncresult.h: Port all doc comments to gi-docgen 2024-06-29 00:14:35 +05:30
Sudhanshu Tiwari
62acd02c49 gasyncresult.c: Port all doc comments to gi-docgen 2024-06-29 00:11:30 +05:30
Philip Withnall
ebe609eeef
tests: Rearrange double/int comparisons in srvtarget to avoid casts
By keeping `expected` as a `double` for longer, we avoid having to cast
when populating the elements of `ordering`, to avoid
`-Wfloat-conversion` warnings.

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

Helps: #3405
2024-06-28 14:25:38 +01:00
Philip Withnall
2713255574
glib: Add explicit casts for some double → other numeric type conversions
If we enable `-Wfloat-conversion`, these warn about a possible loss of
precision due to an implicit conversion from `double` to some other
numeric type.

The warning is correct: there is a possible loss of precision here. In
these instances, we don’t care, as the floating point arithmetic is
being done to do some imprecise scaling or imprecise timing. A loss of
precision is not a problem.

So, add an explicit cast to squash the warning.

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

Helps: #3405
2024-06-28 14:24:55 +01:00
Gary Li
d64336e1a9 g_output_stream_write: Allow NULL buffer if count is 0
We currently fail a buffer != NULL assertion if buffer is NULL and count is 0. Allow this case without critical assertions.

Fixes https://gitlab.gnome.org/GNOME/glib/-/issues/3402
2024-06-26 14:18:41 -04:00
rong wang
478127e074 GLocalFile: support trashing long file name
When the file name is too long (for example, more than 238 bytes on
ext4), this will cause the creation of the .trashinfo file to fail.
Let's shorten the .trashinfo filename in this case, after all the
trash specification only requires unique filenames (see
`Contents of a trash directory` section in
https://specifications.freedesktop.org/trash-spec/trashspec-latest.html).
2024-06-19 10:27:33 +01:00
Philip Withnall
cce6ca8c88
tests: Improve 4GB file loading test to work on i386
This should test the limits of loading 4GB files on i386 platforms, such
as the Hurd CI runner. On such platforms, `sizeof(size_t) == 4`.

This should fix the compiler warning from
https://gitlab.gnome.org/GNOME/glib/-/jobs/3989442:
```
../gio/tests/file.c:2931:51: error: left shift count >= width of type [-Werror=shift-count-overflow]
 2931 | static const gsize testfile_4gb_size = ((gsize) 1 << 32) + (1 << 16); /* 4GB + a bit */
      |                                                   ^~
cc1: all warnings being treated as errors
```

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-18 12:58:51 +01:00
Philip Withnall
1f838b061b
tests: Skip >4GB file tests unless running tests in slow/thorough mode
They take too long to include in a normal test run. They’ll still be run
in CI once a week as part of our scheduled slow test job.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-17 13:03:08 +01:00
Philip Withnall
a8be45204e tests: Fix a typo in a test name in the file test suite
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-17 13:03:05 +01:00
Benjamin Otte
e74294473e tests: Add test for >4GB reads with g_file_load_contents()
The tests - one for sync, one for async - create a sparse file for
this purpose, so this should be cheap on the fileystem.

Of course, the test still allocates >4GB of memory for the data that it
returns from g_file_load_contents(), I hope the CI test runners can deal
with that.
2024-06-17 13:03:05 +01:00
Benjamin Otte
77c35415a3 tests: Use g_clear_fd() 2024-06-17 13:03:05 +01:00
Benjamin Otte
e8254f14fd gfile: Rewrite load_contents() to use realloc()
GByteArray is limited to 4GB in size and the current code silently
overflows when that happens.

Replace both load_contents() and load_contents_async() implementations
with a version that uses realloc() and gsize to maintain the array.
2024-06-17 13:03:05 +01:00
Philip Withnall
577ad8d07d
tests: Use g_assert_*() rather than g_assert() in notification tests
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-06-14 23:05:25 +01:00
Luca Bacci
2cf0ce39aa glocalfileinfo: Use stat results only if stat succeeded 2024-06-14 17:42:39 +01:00
Luca Bacci
3ae88886ac glocalfileinfo: Do not set G_FILE_ATTRIBUTE_ID_STANDARD_IS_BACKUP twice 2024-06-14 17:42:39 +01:00
Natanael Copa
2c042cd466 tests: find update-desktop-database
Disable tests that require update-desktop-database when it is missing.

It requires glib to build so it will be missing when bootstrapping glib.

Refactor the ifdef for Windows and MacOS while at it and reduce number
of ifdefs.

Ref: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3658
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2024-06-14 16:35:44 +01:00
Natanael Copa
7322a925e2 tests: skip tests that requires dbus-daemon when its missing
dbus may not be built yet during bootstrap, because it needs glib to
build.

Ref: https://gitlab.gnome.org/GNOME/glib/-/issues/3317
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2024-06-14 16:35:44 +01:00
Natanael Copa
6a262b0c03 tests: skip test that requires shared-mime-info when its missing
shared-mime-info required glib to build and will not be there during
bootstrap. Skip the test if it is missing.

ref: https://gitlab.gnome.org/GNOME/glib/-/issues/3317
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2024-06-14 16:35:44 +01:00
Philip Withnall
9e680ff8f4 Merge branch 'wip/pwithnall/gsocket-eaddrnotavail-macos' into 'main'
gioerror: Map EADDRNOTAVAIL to G_IO_ERROR_CONNECTION_REFUSED

Closes #3394

See merge request GNOME/glib!4111
2024-06-13 19:57:24 +00:00
Philip Withnall
f09a8e2be4
gioerror: Map EADDRNOTAVAIL to G_IO_ERROR_CONNECTION_REFUSED
Previously it was mapped (as a default) to `G_IO_ERROR_FAILED`.

It’s the error that macOS returns when trying to connect to a socket which
is bound but not listened to. Linux returns `ECONNREFUSED` in this case.
It’s helpful if they both map to the same `GIOError` value.

This should fix the `/socket-client/connection-fail` test on macOS,
which is currently
[failing](https://gitlab.gnome.org/GNOME/glib/-/jobs/3970547) with:
```
 # GLib-GIO-DEBUG: GSocketClient: Starting TCP connection attempt
 # GLib-GIO-DEBUG: GSocketClient: Connection attempt failed: Can't assign requested address
 # GLib-GIO-DEBUG: GSocketClient: Starting new address enumeration
 # GLib-GIO-DEBUG: GSocketClient: Address enumeration completed (out of addresses)
 # GLib-GIO-DEBUG: GSocketClient: Address enumeration failed: (null)
 # GLib-GIO-DEBUG: GSocketClient: Connection failed: Could not connect to localhost: Can't assign requested address
not ok /socket-client/connection-fail - GLib-GIO:ERROR:../gio/tests/gsocketclient-slow.c:231:test_connection_failed: assertion failed (local_error == (g-io-error-quark, 39)): Could not connect to localhost: Can't assign requested address (g-io-error-quark, 0)
Bail out!
```

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

See: #3184
Fixes: #3394
2024-06-13 20:00:12 +01:00
José Guilherme
efe2c24757 gdbus: factor out untranslatable parts of error messages 2024-06-13 18:30:58 +00:00
Biswapriyo Nath
7e69f88480 gcontenttype-win32: Copy documetation comment from gcontenttype
Fixes https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/509
2024-06-09 14:30:03 +00:00
Philip Withnall
601b8b45fb Merge branch '3184-socket-client-leak-with-unit-test' into 'main'
gsocketclient: Unit test for "Fix a leak of the task data on an error path"

Closes #3184

See merge request GNOME/glib!4104
2024-06-05 12:08:33 +00:00
Johan Sternerup
61e006e16c gsocketclient: Add unit test for leak of task data in error path
The unit test cover the error path that causes the leak described in
https://gitlab.gnome.org/GNOME/glib/-/issues/3184.
2024-06-05 12:54:15 +01:00
Philip Withnall
234871f1f9
gsocketclient: Fix a leak of the task data on an error path
Once the task is completed (and `g_task_return_*()` has been called),
the task is no longer needed. It would make more sense to unref it in
`complete_connection_with_error()`, where `g_task_return_*()` is called,
but that complicates other call sites significantly, so I didn’t do it.

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

Fixes: #3184
2024-06-05 12:54:05 +01:00
Bilal Elmoussaoui
b845d04918 gio/g-i: Mark Application:action-group property as deprecated
To avoid bindings making use of it
2024-06-04 14:38:02 +00:00
Maximiliano Sandoval
a7557f125e
gfile: Fix finish-func annotations
The finish-func should not contain the library_class prefix.
2024-06-01 16:49:34 +02:00
Philip Withnall
04de380f74 Merge branch 'wip/smcv/gdbusconn-comment' into 'main'
gdbusconnection: Fix a misleading comment

See merge request GNOME/glib!4063
2024-05-16 23:42:06 +00:00
Simon McVittie
434c105bbe gdbusconnection: Fix a misleading comment
While backporting CVE-2024-34397 fixes I noticed that this comment
claimed that the reference count is immutable after construction, which
is clearly not true. In fact the reference count is the only
mutable field.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:53:11 +01:00
Simon McVittie
510d0716be gdbus: Use symbolic constants for the most common D-Bus error names
To avoid adding a large block of macros to gdbusprivate.h, I've only
added a subset of the well-known error names. I chose to draw the
line by adding constants for the errors emitted via their string names
in GDBusConnection, but not for error names that are only mentioned
in `gdbuserror.c` or in tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
7c609f8142 gdbus: Use symbolic constants for interfaces from dbus-specification
Most D-Bus interfaces are domain-specific, but these interfaces from the
D-Bus Specification are intended to be commonly used in any context for
which they are found to be appropriate.

Most of these use `gdbusprivate.h`. One exception is that
`gio/tests/gdbus-example-*` redefine the constants locally: due to these
files' dual role as part of the unit tests and as sample code, it seems
desirable to ensure that they can still be compiled outside GLib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
b4f8d4a5d5 gdbus: Use symbolic constants for the reserved Local path and interface
These are reserved by the D-Bus Specification.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
7401577074 gdbus: Move protocol constants from gdbusdaemon into gdbusprivate.h
These well-known flags and replies are part of the D-Bus Specification,
and also exist with the same names in libdbus header files.
Moving them into a private header means that unit tests like
gdbus-proxy-threads and gdbus-subscribe don't have to reinvent them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
b0e8612a3b gdbusdaemon: Use shared constants for message bus name, path, interface
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
131a061aca gdbus: Use symbolic constants for various references to the message bus
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
19223803f5 gdbus: Use symbolic constants to subscribe to message bus signals
Unlike the various functions to call D-Bus methods, these sort their
arguments in a non-obvious order (bus name, interface, signal, path),
presumably aiming to sort the most-likely-to-be-used arguments first.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:23 +01:00
Simon McVittie
fe14968c0d gdbus: Use symbolic constants to call message bus methods
These function arguments are arranged in the obvious order from
conceptually largest to smallest: (bus name, path, interface, method).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:22 +01:00
Simon McVittie
2151a82007 gdbus tests: Fix a typo
This test was subscribing to the NameOwnerChanged signal with an
incorrect object path, so the callback would never be called. In this
particular case it doesn't actually matter, because the callback does
nothing anyway (the purpose of this particular test was to test that
the user-data is freed on unsubscription).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-05-16 22:52:22 +01:00
Michael Catanzaro
b9490a499a Merge branch '3366-menu-exporter-error-handling' into 'main'
gmenuexporter: Fix a NULL pointer dereference on an error handling path

Closes #3366

See merge request GNOME/glib!4073
2024-05-15 14:55:18 +00:00
Philip Withnall
7a7137838e
gactiongroupexporter: Fix memory problems on an error handling path
Almost identically to the previous commit, fix a similar latent bug in
`g_dbus_connection_export_action_group()`, which was not ready to handle
the fledgling `GActionGroupExporter` being freed early on an error
handling path.

See the previous commit message for details of the approach.

This includes a unit test.

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

Fixes: #3366
2024-05-15 14:00:09 +01:00
Philip Withnall
df2c5d925a
gmenuexporter: Fix a NULL pointer dereference on an error handling path
This latent bug wasn’t triggered until commit 3f30ec86c (or its
cherry-pick onto `glib-2-80`, 747e3af99, which was first released in
2.80.1).

That change means that `g_menu_exporter_free()` is now called on the
registration failure path by `g_dbus_connection_register_object()`
before it returns. The caller then tries to call `g_slice_free()` on the
exporter again. The call to `g_menu_exporter_free()` tries to
dereference/free members of the exporter which it expects to be
initialised — but because this is happening in an error handling path,
they are not initialised.

If it were to get any further, the `g_slice_free()` would then be a
double-free on the exporter allocation.

Fix that by making `g_menu_exporter_free()` robust to some of the
exporter members being `NULL`, and moving some of the initialisation
code higher in `g_dbus_connection_export_menu_model()`, and removing the
duplicate free code on the error handling path.

This includes a unit test.

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

Fixes: #3366
2024-05-15 12:52:38 +01:00