Commit Graph

5220 Commits

Author SHA1 Message Date
Daniel Boles
0d953f8dd2 GSettings: Don't mention nonexistent signal in doc
https://bugzilla.gnome.org/show_bug.cgi?id=622126
2018-04-09 14:15:46 +01:00
Daniel Boles
ff0c30b516 GSimpleAction: Slightly improve docs for new()s
Explain why we say "See new_stateful()" (although it's pretty obvious).
Drop a redundant copy of the argument description in the body text.
Add a # to the GVariant type name so that we can have a nice link.

https://bugzilla.gnome.org/show_bug.cgi?id=795070
2018-04-09 13:28:34 +01:00
Daniel Boles
21348867fe GSimpleAction: Explain "(expected|correct) type"
Let's avoid users having to infer what these mean; it's easy to explain.

https://bugzilla.gnome.org/show_bug.cgi?id=795070
2018-04-09 13:28:34 +01:00
Daniel Boles
75021c6c6e GSimpleAction: Clarify/fix @parameter(_type) docs
If something is nullable, it's always helpful to identify what NULL
means. Also, this is not the parameter for the .activate() vfunc, as we
take that over: rather, it is the parameter for the ::activate signal.

https://bugzilla.gnome.org/show_bug.cgi?id=795070
2018-04-09 13:28:33 +01:00
Xavier Claessens
dad4f956c5 Meson: Add carbon and cocoa flags into glib and gio pc files
https://bugzilla.gnome.org/show_bug.cgi?id=788773
2018-03-28 19:31:25 -04:00
Xavier Claessens
3c76114e73 Meson: Use pkgconfig module to generate all pc files
This requires improved pc file generator from meson 0.45.

https://bugzilla.gnome.org/show_bug.cgi?id=788773
2018-03-28 19:31:20 -04:00
Emmanuele Bassi
ac42183c33 Initialize variable
The `mount_monitor` variable is only set if the boolean
`with_mount_monitor` variable is set to TRUE, but the compiler does not
know that, so it'll warn when calling `g_clear_object()` even if the
clearing operation is gated with the same boolean.

Initializing with NULL does not cost us anything, and eliminates a
conditional branch.

https://bugzilla.gnome.org/show_bug.cgi?id=794732
2018-03-28 11:49:59 +01:00
Emmanuele Bassi
dd8d33d968 Initialize boolean variable
There can be branches where the `interesting` variable isn't
initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=794732
2018-03-28 11:49:59 +01:00
Emmanuele Bassi
07731ff3fc Do not use g_autofree
The g_auto macros are available only with GCC-compatible compilers on
Unix, but having __attribute__((cleanup)) is not part of our toolchain
requirements, so we shouldn't use it — even if we are building on
Unix-compatible systems.

https://bugzilla.gnome.org/show_bug.cgi?id=794732
2018-03-28 11:49:59 +01:00
Ting-Wei Lan
ba4a9538e1 gpollfilemonitor: Fix use-after-free caused by leaking GSource
https://bugzilla.gnome.org/show_bug.cgi?id=794528
2018-03-26 10:55:44 +01:00
Sebastian
e2c16df4b5 gthreadedresolver: Fix compilation with res_nclose() but no res_nquery()
Some very odd systems have the functions to initialise and destroy a
struct __res_state, but apparently not to do a DNS query using it. Fix
the compilation on those systems.

https://bugzilla.gnome.org/show_bug.cgi?id=794606
2018-03-26 10:49:25 +01:00
Matthias Clasen
7e4a0d8479 GIO: avoid a crash in calling portals
When the OpenUri portal call fails, we were possibly
freeing uninitialized memory. Avoid that by initializing
path to NULL here.

See https://github.com/flatpak/xdg-desktop-portal/issues/173
2018-03-25 00:10:21 -04:00
Philip Withnall
891026d9fc giomodule: Fix a copy/paste error in some internal documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-03-21 15:32:13 +00:00
Philip Withnall
d1077304ec gsocketlistener: Document the need to call g_socket_listener_close()
GSocketListener can keep internal references to itself for pending
accept() calls, which mean that it can stay alive (and keep listening
on ports) even after a user drops their last reference to it. They need
to call g_socket_listener_close() explicitly to avoid that.

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

https://bugzilla.gnome.org/show_bug.cgi?id=794207
2018-03-14 17:21:28 +00:00
Philip Withnall
dd815c3d2b gsocketlistener: Fix a typo in the documentation
Mismatched singular/plural.

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

https://bugzilla.gnome.org/show_bug.cgi?id=794207
2018-03-14 17:21:27 +00:00
Emmanuele Bassi
b4117b8d88 Conditionally warn if pre-processing tools are not found
There's no need to unconditionally print an error message if xmllint or
json-glib-format are not found when running glib-compile-resources is
called; we only need to warn if they are not available when we need
them. To avoid spamming the build logs, we can also warn once.

https://bugzilla.gnome.org/show_bug.cgi?id=794285
2018-03-14 14:21:41 +00:00
Emmanuele Bassi
72402877cc Use g_file_open_tmp() instead of hand-rolling it
The glib-compile-resources tool has hand-rolled "open a temporary file"
code paths. Since error handling is hard, let's rely on GLib API that is
meant to do that consistently for us.

Get rid of some tabs mixed with spaces while we're at it.

https://bugzilla.gnome.org/show_bug.cgi?id=794284
2018-03-14 11:48:13 +00:00
Emmanuele Bassi
7fd17c4337 Support whitespace stripping for JSON resources
Similarly to how glib-compile-resources can call xmllint to eliminate
whitespace in XML files to reduce their size inside a GResource, we can
use json-glib-format to achieve the same result.

The mechanism for using json-glib-format is the same, with a separate
environment variable if we want to direct glib-compile-resources to a
version of json-glib-format that is not the one in the PATH.

https://bugzilla.gnome.org/show_bug.cgi?id=794284
2018-03-14 11:46:17 +00:00
Philip Withnall
c672fcc0a8 gunixmounts: Allow root to display mounts under /run/media/$username
Normally, the list of mounts is filtered to exclude mounts in
/run/media/$username where $username is not the current user. However,
root can access all the mounts under /run/media/, regardless of the
username — so there’s no point in filtering out those mounts.

In some cases, filtering them out is harmful. In the case of a system
service which uses GVolumeMonitor, for example, filtering them out means
the service cannot see automounted USB sticks belonging to user
sessions.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793994
2018-03-13 12:55:16 +00:00
Philip Withnall
7c1f38b1c9 gapplication: Tighten up application ID validation
Tighten up the validation of application IDs so they are always exactly
D-Bus well-known names. This is a slight change to the accepted format,
but since anyone using the API with an application ID which was
previously valid, but which was not a valid D-Bus well-known name, would
have received an error from D-Bus when their application tried to
register on the bus, I think this break is acceptable.

It will affect any applications which have application IDs which are not
valid D-Bus well-known names, and which use the G_APPLICATION_NON_UNIQUE
flag. From a quick search in Debian Codesearch, no C applications use
that flag.

Update the documentation to use the rules from the D-Bus specification,
including the latest advice discouraging use of hyphens:

https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus

Update the tests:
 • Add the examples from the documentation to validate them.
 • Especially the venerable 7-zip.org example.
 • Move a couple of tests from expected-failure to expected-success:
   they are valid D-Bus well-known names even if they’re a bit weird.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793400
2018-03-13 12:45:13 +00:00
Philip Withnall
b046c5b772 tests: Use modern test assertions in GApplication test
This will make the assertion failure messages a little more useful, and
prevent the assertions being compiled out with G_DISABLE_ASSERT.
Introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793400
2018-03-13 12:45:13 +00:00
Martin Pieuchot
aa39a0557c kqueue: Multiple fixes and simplifications
- Stop using a custom thread for listening to kqueue(2) events.  Instead
   call kevent(2) in non blocking mode in a monitor callback.  Under the
   hood poll(2) is used to figure out if new events are available.

 - Do not use a socketpair with a custom protocol requiring 2 supplementary
   context switches per event to commicate between multiple threads.  Calling
   kevent(2), in non blocking mode, to add/remove events is fine from any
   context.

 - Add kqueue(2) events without the EV_ONESHOT flag.  This removes a race
   where some notifications were lost because events had to be re-added for
   every new notification.

 - Get rid of the global hash table and its associated lock and races.  Use
   the 'cookie' argument of kevent(2) to pass the associated descriptor when
   registering an event.

 - Fix _kh_file_appeared_cb() by properly passing a monitor instead of a
   source to g_file_monitor_emit_event().

 - Properly refcount sources.

 - Remove a lot of abstraction making it harder to fix the remaining issues.

https://bugzilla.gnome.org/show_bug.cgi?id=739424
2018-03-13 12:23:10 +00:00
Руслан Ижбулатов
aab83f7475 gdbus: make hexencode() a shared function to avoid duplication
https://bugzilla.gnome.org/show_bug.cgi?id=794170
2018-03-13 12:09:01 +00:00
Руслан Ижбулатов
cc7ab04b33 gdbus: do not initialize gsize variables with -1
Use 0 instead, since gsize is unsigned.

https://bugzilla.gnome.org/show_bug.cgi?id=794170
2018-03-13 12:09:01 +00:00
Руслан Ижбулатов
249330c388 gdbus: pass string length to hexencode()
This is necessary for it to be able to encode strings
with embedded NUL characters.

https://bugzilla.gnome.org/show_bug.cgi?id=794170
2018-03-13 12:09:01 +00:00
Руслан Ижбулатов
f7c0ff773e gdbus: actually return string length from hexdecode()
https://bugzilla.gnome.org/show_bug.cgi?id=794170
2018-03-13 12:09:01 +00:00
Philip Withnall
8266238f6d gnetworkmonitornm: Use g_strv_contains() rather than reinventing it
This introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
35d4c7f898 gnetworkmonitornm: Fix some minor GVariant memory leaks
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
61a899815b gnetworkmonitornetlink: Fix a memory leak in unusual circumstances
If the GNetworkMonitorNetlink is finalised part-way through a dump
(after request_dump() is called, but before finish_dump() is called),
dump_networks was leaked. Fix that.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
183c846b30 gnetworkmonitornetlink: Fix memory leaks on error paths
Use a common error handler to avoid leaks on the error paths.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
88bf4939f6 gnetworkmonitornetlink: Refactor some code to reduce duplication
This should introduce no functional changes. Factor out some common
code, flip some arguments around to use the more conventional (data,
length) order, and move some memory management calls out of
if-blocks.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
23fad11430 gnetworkmonitornetlink: Use a coarser-grained timer for dumps
By using g_timeout_source_new_seconds(), we can let timer wakeups be
coalesced by the scheduler, and reduce power consumption a bit. This
shouldn’t really affect the accuracy of the network monitoring.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
85f3bc133f gnetworkmonitornetlink: Fix potential GMainContext issue
Previously, the GSource would be attached to whatever GMainContext was
the thread default at the time; but that might no longer be the same as
the default at the time of constructing the GNetworkMonitor.

Save the default from construction time, so that source callbacks are
always invoked in the same GMainContext.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Christophe Fergeau
29df0b98da gio: Fix 'overide' typo in g_network_address_parse doc
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-02-28 15:07:27 +01:00
Erik van Pienbroek
f5d1ac0d40 GNetworkMonitorBase: don't fail when IPv6 support is unavailable
https://bugzilla.gnome.org/show_bug.cgi?id=733338
2018-02-27 12:05:43 +00:00
Dr. Michael Lauer
170466db26 gio: fix compiling on macOS by moving all Objective-C file into libgio-objc-2.0
Previously, only gnextstepsettingsbackend.c was taken into account.

https://bugzilla.gnome.org/show_bug.cgi?id=793565
2018-02-27 11:04:24 +00:00
Philip Withnall
0cf523e791 gdbus-tool: Factor out common GOptionContext construction
In doing so, ensure that g_option_context_set_ignore_unknown_options()
is always called if completion is being done.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793597
2018-02-21 14:20:59 +00:00
Iain Lane
e2d9884958 gdbus-tool: Don't repeatedly complete --signal
In this situation:

  $ gdbus emit --session --object-path /org/foo/bar --sig<tab><tab><tab>

We will currently insert --signal three times.

We should only do that once.

https://bugzilla.gnome.org/show_bug.cgi?id=793597
2018-02-21 14:00:51 +00:00
Iain Lane
2a2717062b gdbus-tool: Make --dest optional for emit again
Commit faf9440908 made the bash completion more
robust, but in doing so it made the optional --dest argument to `gdbus emit'
mandatory by mistake.

Remove the error case when --dest is not specified. To keep the completion
working, we shuffle the cases around. --dest should be offered up for
completion after --session/--system/--address have been supplied, so we can
complete its argument. Additionally, if --dest isn't specified then we can't
complete --object-path or --signal, so guard these completions accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=793597
2018-02-21 14:00:51 +00:00
Iain Lane
1717a8c965 gdbus-tool: Ignore unknown options for the 'emit' subcommand when completing
When completing, we parse the options that the user has typed so far. Up
until now we've been doing this without ignoring unknown options. This
leads to broken completions when the user has typed an incomplete
parameter.

For example, when doing the following:

  $ gdbus emit --session --obj<tab>

We expect --object-path to be completed, but it is currently not. What
happens is that we fail to parse the options, therefore don't act on
--session and so don't connect to the session bus, then we early-exit
because we need to know which bus to operate on for later completions.

Instead we can ignore the half-completed --obj, parse --session, get
connected to the bus and then move on to the later completion code.

https://bugzilla.gnome.org/show_bug.cgi?id=793597
2018-02-21 14:00:51 +00:00
Ernestas Kulik
03e86d000f Remove HAVE_CONFIG_H defs and uses
Since GLib files are only meant to be built as part of GLib, config.h
always exists, so the checks are more or less pointless.

https://bugzilla.gnome.org/show_bug.cgi?id=793399
2018-02-21 13:57:10 +00:00
Ernestas Kulik
4f942122b7 gio: tests: modules: declare _get_type prototype
GCC complains about non-static functions being defined without a
previous prototype, even if they themselves provide one.

https://bugzilla.gnome.org/show_bug.cgi?id=793399
2018-02-21 10:56:31 +00:00
Emmanuele Bassi
d8a3492fce Allow running gdbus-peer inside a container
The /etc/machine-id inside a Docker container is allowed to be empty, so
we need to check for that case.

https://bugzilla.gnome.org/show_bug.cgi?id=793635
2018-02-20 13:49:21 +00:00
Tim-Philipp Müller
03d06c175f gwin32networkmonitor: fix build with MSVC
Don't include unistd.h unconditionally.
2018-02-20 00:56:35 +00:00
Philip Withnall
22b224862c tests: Add a debug message to gdbus-peer test
This might help diagnose the CI test failure here:
https://gitlab.gnome.org/GNOME/glib/-/jobs/8222

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-02-19 11:11:36 +00:00
Ernestas Kulik
c01c255895 tests: data-input-stream: fix -Wduplicated-branches
The fix makes things a bit awkward, but it seems to work just fine.

https://bugzilla.gnome.org/show_bug.cgi?id=793399
2018-02-16 17:38:26 +00:00
Philip Withnall
a66fc8e3a9 gfile: Fix FD leak introduced in error path in previous commit
The hazards of ‘just a quick fix and I will push’.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-02-16 12:03:47 +00:00
Andrés Souto
a5778ef7c5 gio: bump splice copy buffer size to 1024k
This change increases throughput when copying files for some filesystems

(Modified by Philip Withnall <withnall@endlessm.com> to add more error
handling.)

https://bugzilla.gnome.org/show_bug.cgi?id=791457
2018-02-16 11:54:56 +00:00
Philip Withnall
2ffba0e262 gdatainputstream: Document the returned string is always nul-terminated
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody

https://bugzilla.gnome.org/show_bug.cgi?id=742124
2018-02-16 11:15:02 +00:00
Philip Withnall
0664b61782 gdbusconnection: Fix error in g_dbus_connection_emit_signal() docs
It incorrectly said that an error could only be returned if the GVariant
was incorrect for the D-Bus API, but that’s not true: an error will also
be returned if you call it on a closed GDBusConnection.

Clarify that, and mention the actual error codes which are returned.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-02-15 16:42:26 +00:00