Commit Graph

768 Commits

Author SHA1 Message Date
Philip Withnall
159a9c215a gio: Fix various typos of the name ‘D-Bus’
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-10-26 14:28:15 +00:00
Sergio Costas
c12762a091 GSubprocessLauncher: allow to close passed FDs
By default, when using g_subprocess_launcher_take_fd() to pass an
FD to a child, the GSubprocessLauncher object also takes ownership
of the FD in the parent, and closes it during finalize(). This is
a reasonable assumption in the majority of the cases, but sometimes
it isn't a good idea.

An example is when creating a GSubprocessLauncher in JavaScript:
here, the destruction process is managed by the Garbage Collector,
which means that those sockets will remain opened for some time
after all the references to the object has been droped. This means
that it could be not possible to detect when the child has closed
that same FD, because in order to make that work, both FDs
instances (the one in the parent and the one in the children) must
be closed. This can be a problem in, as an example, a process that
launches a child that communicates with Wayland using an specific
socket (like when using the new API MetaWaylandClient).

Of course, it isn't a valid solution to manually call close() in
the parent process just after the call to spawn(), because the FD
number could be reused in the time between it is manually closed,
and when the object is destroyed and closes again that FD. If that
happens, it will close an incorrect FD.

One solution could be to call run_dispose() from Javascript on the
GSubprocessLauncher object, to force freeing the resources.
Unfortunately, the current code frees them in the finalize()
method, not in dispose() (this is fixed in !1670 (merged) ) but it
isn't a very elegant solution.

This proposal adds a new method, g_subprocess_launcher_close(),
that allows to close the FDs passed to the child. To avoid problems,
after closing an FD with this method, no more spawns are allowed.

Fix: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1677
2020-10-12 20:29:48 +02:00
Maxim Mikityanskiy
094eca7076 gio: Expose g_file_build_attribute_list_for_copy
Expose a function that prepares an attribute query string to be passed
to g_file_query_info() to get a list of attributes normally copied with
the file. This function is used by the implementation of
g_file_copy_attributes, and it's useful if one needs to split
g_file_copy_attributes into two stages, for example, when nautilus does
a recursive move of a directory. When files are moved from the source
directory, its modification time changes. To preserve the mtime on the
destination directory, it has to be queried before moving files and set
after doing it, hence these two stages.

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
2020-10-06 10:16:49 +01:00
Patrick Griffis
f9fc29f0b7 gtlscertificate: Add support for PKCS #11 backed certificates
This reverts commit d58e5de9e9.
2020-10-01 17:09:04 +01:00
Simon McVittie
d65c8c30a9 GDBus: Add G_DBUS_METHOD_INVOCATION_HANDLED, _UNHANDLED
Like G_SOURCE_REMOVE and G_SOURCE_CONTINUE, these make it clearer what
it means to return TRUE or FALSE.

In particular, in GDBus methods that fail, the failure case still needs
to return TRUE (unlike the typical GError pattern), leading to comments
like this:

    g_dbus_method_invocation_return_error (invocation, ...);
    return TRUE;    /* handled */

which can now be replaced by:

    g_dbus_method_invocation_return_error (invocation, ...);
    return G_DUS_METHOD_INVOCATION_HANDLED;

G_DBUS_METHOD_INVOCATION_UNHANDLED is added for symmetry, but is very
rarely (perhaps never?) useful in practice.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-10-01 16:32:50 +01:00
Philip Withnall
c51a8ce8c8 gversionmacros: Add version macros for GLib 2.68
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-10-01 14:33:21 +01:00
Ondrej Holy
0d6b17584a gunixmounts: Add g_unix_mount_point_at
There is already g_unix_mount_at function which allows to find certain
unix mount for given mount path. It would be useful to have similar
function for mount points, which will allow to replace custom codes in
gvfs. Let's add g_unix_mount_point_at.
2020-08-05 13:07:04 +01:00
Nirbheek Chauhan
4e485d76ac gio: Remove broken support for XP
We now require Windows 7 or newer, and the networking code hasn't
worked in a long time since we directly use symbols from iphlapi.dll
now.
2020-07-26 21:30:05 +05:30
Ruslan Marchenko
44524b9daa Add g_(d)tls_connection_get_channel_binding_data calls and enums
* Add g_tls_connection_get_channel_binding_data API call
 * Add g_dtls_connection_get_channel_binding_data API call
 * Add get_binding_data method to GTlsConnection class
 * Add get_binding_data method to GDtlsConnection interface
 * Add GTlsChannelBindingType enum with tls-unique and
   tls-server-end-point types
 * Add GTlsChannelBindingError enum and G_TLS_CHANNEL_BINDING_ERROR
   quark
 * Add new API calls to documentation reference gio-sections-common
2020-06-25 12:40:34 +00:00
Philip Withnall
00bfb3ab44 tree: Fix various typos and outdated terminology
This was mostly machine generated with the following command:
```
codespell \
    --builtin clear,rare,usage \
    --skip './po/*' --skip './.git/*' --skip './NEWS*' \
    --write-changes .
```
using the latest git version of `codespell` as per [these
instructions](https://github.com/codespell-project/codespell#user-content-updating).

Then I manually checked each change using `git add -p`, made a few
manual fixups and dropped a load of incorrect changes.

There are still some outdated or loaded terms used in GLib, mostly to do
with git branch terminology. They will need to be changed later as part
of a wider migration of git terminology.

If I’ve missed anything, please file an issue!

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-12 15:01:08 +01:00
Chun-wei Fan
cd229a2fb4 docs: Document --symbol-decorator for gdbus-codegen
This updates gdbus-codegen.xml to include documentation for the
--symbol-decorator, --symbol-decorator-header and
--symbol-decorator-define options, which is used to help to export
symbols in the generated code.
2020-05-28 18:24:57 +08:00
Philip Withnall
9f421dd678 docs: Add indexes for symbols added in 2.66
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-05-20 12:20:28 +01:00
Ondrej Holy
5737d064f9 docs: Mention new gio tool options
New features were added for gio tool, but they are not mentioned in
man pages as it is not generated from GOptionEntry in contrast to the
help output. Let's update the man pages to reflect the recent changes.
2020-04-02 13:23:09 +02:00
Chris Mayo
84ad802c3a docs: Fix configuration with gtk_doc=true and installed_tests=false
Skip the gdbus-object-manager-example which is generated as part of
testing.

Program xsltproc found: YES (/usr/bin/xsltproc)
Run-time dependency gtk-doc found: YES 1.32

docs/reference/gio/gdbus-object-manager-example/meson.build:1:0: ERROR:
Unknown variable "libgdbus_example_objectmanager_dep".
2020-03-27 19:33:12 +00:00
Philip Withnall
760c8ccbe6 docs: Don’t install object manager example separately
The relevant parts of the generated example documentation are already
`xi:include`d into the `migrating-gdbus.xml` page, so are turned into
HTML there. Installing them separately means they also get installed
into `/usr/share/gtk-doc/html/gdbus-object-manager-example/`, which
seems redundant.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-11 11:47:03 +00:00
Philip Withnall
a0e74a8c47 Merge branch '1993-codegen-version-args' into 'master'
Rename gdbus-codegen --glib-min-version argument to --glib-min-required and add --glib-max-allowed

Closes #1993

See merge request GNOME/glib!1342
2020-01-31 13:49:20 +00:00
Philip Withnall
e855e30d6d Merge branch 'gtkdoc-check-fix' into 'master'
Various fixes to make gtkdoc-check pass on glib

See merge request GNOME/glib!978
2020-01-31 13:23:42 +00:00
Philip Withnall
c07d9434f4 Merge branch 'wip/oholy/gfile-docs' into 'master'
Symlink-related fixes for `g_file_move()`

Closes #986

See merge request GNOME/glib!900
2020-01-31 12:56:15 +00:00
Michael Catanzaro
d58e5de9e9 Revert "gtlscertificate: Add support for PKCS #11 backed certificates"
This reverts commit b6d8efbebc.

This GLib API is good, but the implentation is not ready, so there's no
reason to commit to the API in GLib 2.64. We can reland again when the
implementation is ready.

There are three problems: (a) The glib-networking implementation normally
works, but the test has been broken for a long time. I'm not comfortable
with adding a major new feature without a working test. This is
glib-networking#104. (b) The WebKit implementation never landed. There
is a working patch, but it hasn't been accepted upstream yet. This API
isn't needed in GLib until WebKit is ready to start using it.
https://bugs.webkit.org/show_bug.cgi?id=200805. (c) Similarly, even if
the WebKit API was ready, that itself isn't useful until an application
is ready to start using it, and the Epiphany level work never happened.

Let's try again for GLib 2.66. Reverting this commit now just means we
gain another six months before committing to the API forever. No reason
to keep this in GLib 2.64 when nothing is using it yet.
2020-01-30 04:19:22 -06:00
Xavier Claessens
09d995286b doc: Run gtkdoc-check with unit tests
This has the side effect of always rebuilding the doc at each build when
gtk_doc option is enabled (not by default). Most importantly, this will
enable doc check on our CI.
2020-01-29 15:54:53 +01:00
Xavier Claessens
74bb6c98cb doc: add missing indexes 2020-01-29 15:54:53 +01:00
Xavier Claessens
6e8a7c2cd4 doc: Add back gdbus-object-manager-example
This requires Meson 0.52.0 for the return value of gnome.gtkdoc().
2020-01-29 15:40:17 +01:00
Xavier Claessens
6d05ac2fa9 Revert "docs: remove GDBusObjectManager example"
This reverts commit 398c048c66.

It got removed because it used to cause build issues, but now that we
have a CI let's hope it won't be a problem any more.
2020-01-29 15:40:17 +01:00
Philip Withnall
9734e4854e gdbus-codegen: Add --glib-max-allowed argument
This complements the `--glib-min-required` argument, just like the
`GLIB_MIN_REQUIRED` and `GLIB_MAX_ALLOWED` preprocessor defines which
control access to APIs in C.

Currently, it doesn’t affect code generation at all. When we next change
code generation, we will need to gate any new API usage on this
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1993
2020-01-27 10:42:26 +00:00
Philip Withnall
4d1c3e15f9 gdbus-codegen: Rename --glib-min-version to --glib-min-required
This makes it consistent with the `GLIB_MIN_REQUIRED` defines which are
used for API stability/versioning in C code.

It doesn’t otherwise change the behaviour of the `--glib-min-version`
argument.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1993
2020-01-27 10:11:46 +00:00
wouter bolsterlee
809a9210c3 Support multiple directories in GSETTINGS_SCHEMA_DIR
This adds support for specifying multiple directories in the
GSETTINGS_SCHEMA_DIR environment variable by separating the values
using G_SEARCHPATH_SEPARATOR_S (colon on UNIX-like systems).

While programs could already register multiple custom GSettings schema
directories, it was not possible to achieve the same without writing
custom code, e.g. when using the gsettings command line tool.

Fixes #1998.
2020-01-16 10:20:34 +00:00
Matthew Leeds
2a605f6e15 gdbus-codegen: Add call_flags and timeout_msec args
Currently the code generated by gdbus-codegen uses
G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method
defined by the input XML, and for proxy_set_property functions. This
means that if the daemon which implements the methods checks for
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive
authorization if that flag is present, users of the generated code have
no way to cause the daemon to use interactive authorization (e.g. polkit
dialogs).

If we simply changed the generated code to always use
G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no
way to disallow interactive authorization (except for manually calling
the D-Bus method themselves).

So instead, this commit adds a GDBusCallFlags argument to method call
functions. Since this is an API break which will require changes in
projects using gdbus-codegen code, the change is conditional on the
command line argument --glib-min-version having the value 2.64 or
higher.

The impetus for this change is that I'm changing accountsservice to
properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and
libaccountsservice uses generated code for D-Bus method calls. So
these changes will allow libaccountsservice to continue allowing
interactive authorization, and avoid breaking any users of it which
expect that. See
https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46

It might make sense to also let GDBusCallFlags be specified for property
set operations, but that is not needed in the case of accountsservice,
and would require significant work and breaking API in multiple places.

Similarly, the generated code currently hard codes -1 as the timeout
value when calling g_dbus_proxy_call*(). Add a timeout_msec argument so
the user of the generated code can specify the timeout as well.

Also, test this new API. In gio/tests/codegen.py we test that the new
arguments are generated if and only of --glib-min-version is used with a
value greater than or equal to 2.64, and in gio/tests/meson.build we
test that the generated code with the new API can be linked against.

The test_unix_fd_list() test also needed modification to continue
working now that we're using gdbus-test-codegen.c with code generated
with --glib-min-version=2.64 in one test.

Finally, update the docs for gdbus-codegen to explain the effect of
using --glib-min-version 2.64, both from this commit and from
"gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/
min-version".
2020-01-15 09:37:41 -08:00
Philip Withnall
467b4d6789 docs: Update GMemoryMonitor listings in docs
Fix a few things missed in code review.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-12-16 13:57:28 +00:00
Emmanuele Bassi
4ad429c7ca Merge branch 'revert-1277-i-got-it-wrong' into 'master'
Revert "Revert "docs: remove GDBusObjectManager example""

See merge request GNOME/glib!1282
2019-12-16 12:37:34 +00:00
Emmanuele Bassi
f9bbee7db2 Merge branch '1726-codegen-glib-min-version' into 'master'
gdbus-codegen: Emit GUnixFDLists if an arg has type `h` w/ min-version

Closes #1726

See merge request GNOME/glib!1263
2019-12-12 12:49:34 +00:00
Philip Withnall
df8745fabc Revert "Revert "docs: remove GDBusObjectManager example""
This reverts commit df4fb2cd32.

It needed to be coupled with the other commit from !978, and introduces
breakage into the documentation when compiled by itself. My mistake for
not testing properly.

See discussion on https://gitlab.gnome.org/GNOME/glib/merge_requests/1277#note_666761
2019-12-12 11:30:36 +00:00
Philip Withnall
fcc1367383 Merge branch 'gtkdoc-check-fix' into 'master'
Various gtk-doc improvements

See merge request GNOME/glib!1277
2019-12-11 13:02:20 +00:00
Xavier Claessens
df4fb2cd32 Revert "docs: remove GDBusObjectManager example"
This reverts commit 398c048c66.

It got removed because it used to cause build issues, but now that we
have a CI let's hope it won't be a problem any more.
2019-12-11 12:16:27 +00:00
Bastien Nocera
cd6612dfb7 gio: Add GMemoryMonitor to monitor for low-memory
Add a memory monitor object, with D-Bus and Portal based
implementations. The D-Bus implementation uses the Linux-only
low-memory-monitor Freedesktop project.

Low Memory Monitor D-Bus API:
https://hadess.pages.freedesktop.org/low-memory-monitor/

Android API:
https://developer.android.com/reference/android/content/ComponentCallbacks2.html#onTrimMemory(int)

iOS API:
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle/responding_to_memory_warnings

Win32 API:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.systemevents.lowmemory?view=netframework-4.8

Tizen API:
https://samsung.github.io/TizenFX/master/api/Tizen.Applications.EventManager.SystemEvents.LowMemory.html
2019-12-11 11:44:42 +00:00
Philip Withnall
90f0733858 gdbus-codegen: Add a --glib-min-version argument
This can be used by callers to opt-in to backwards-incompatible changes
to the behaviour or output of `gdbus-codegen` in future. This commit
doesn’t introduce any such changes, though.

Documentation and unit tests included.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1726
2019-12-11 10:40:07 +00:00
Philip Withnall
34cb297a86 Merge branch 'wip/nielsdg/g-list-store-find' into 'master'
gliststore: Add item lookup functions

Closes #1011

See merge request GNOME/glib!1096
2019-11-27 11:22:56 +00:00
Garrett Regier
6cac760551 task: Add return/propagate API for GValue
This is useful for bindings.

Related: https://gitlab.gnome.org/GNOME/glib/issues/668
2019-11-15 10:37:42 +00:00
Philip Withnall
d207e19d32 Merge branch 'wip/tingping/pkcs11' into 'master'
gtlscertificate: Add pkcs11-uri property and constructor

Closes #1809

See merge request GNOME/glib!933
2019-10-03 12:12:16 +00:00
Patrick Griffis
b6d8efbebc gtlscertificate: Add support for PKCS #11 backed certificates
This adds properties to allow backends to expose PKCS #11 support.
2019-10-02 10:12:40 -07:00
Philip Withnall
2268f36769 gio-tool: Add a --default-permissions argument to gio copy
This sets the `G_FILE_COPY_DEFAULT_PERMS` flag on the operation,
creating the copied file with default permissions rather than the same
permissions as the source file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #174
2019-09-30 14:40:50 +01:00
Niels De Graef
14ba521b6d gliststore: Add item lookup functions
Currently, there is no quick way to find whether and element is already
part of a list store, except for manually writing a for-loop and calling
`g_list_model_get_item()` and breaking when you find the item.

This is mostly just a small API addition to support this use case.

Fixes https://gitlab.gnome.org/GNOME/glib/issues/1011
2019-09-25 08:37:22 +02:00
Philip Withnall
d0964b72db docs: Fix typo in GConverter{Input,Output}Stream section titles
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-09-24 12:25:10 +01:00
Xavier Claessens
65f64f0988 Fix doc build on Windows
This is a work around for this Meson bug:
https://github.com/mesonbuild/meson/issues/5893

Closes: #1888
2019-09-09 08:51:46 -04:00
Nirbheek Chauhan
4387f7b7b6 Merge branch '1803-gio-open-docs' into 'master'
docs: Mention environment variables in `gio open` documentation

Closes #1803

See merge request GNOME/glib!1051
2019-08-26 12:22:06 +00:00
Philip Withnall
b2eb0a6f15 docs: Mention environment variables in gio open documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1803
2019-08-25 11:05:07 +03:00
Дилян Палаузов
512655aa12 minor typos in the documentation (a/an) 2019-08-24 19:14:05 +00:00
Philip Withnall
d166a55c64 gfileinfo: Add g_file_info_{get,set}_modification_date_time() APIs
These are alternatives to g_file_info_{get,set}_modification_time(),
which will soon be deprecated due to using the deprecated GTimeVal
type, which is not year 2038 safe.

The new APIs take a GDateTime instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1438
2019-07-29 12:27:29 +01:00
Philip Withnall
249299a76f Merge branch 'doc-fixes' into 'master'
Various doc fixes

See merge request GNOME/glib!982
2019-07-17 10:58:21 +00:00
Emmanuel Fleury
628e448e02 Fixing a small typo in docs/references/gio/gio.xml
Fix issue #1828
2019-07-12 17:49:51 +02:00
Xavier Claessens
e528577202 doc: Add missing GNativeSocketAddress 2019-07-10 10:29:04 -04:00