Commit Graph

5717 Commits

Author SHA1 Message Date
Ondrej Holy
d0821da524 gio: Add g_unix_mount_get_options
GVfsUDisks2VolumeMonitor handles x-gvfs-hide/x-gvfs-show mount options
used to overwrite our heuristics whether the mount should be shown, or
hidden. Unfortunately, it works currently only for mounts with
corresponding fstab entries, because the options are read over
g_unix_mount_point_get_options. Let's introduce g_unix_mount_get_options
to allow reading of the options for all sort of mounts (e.g. created
over pam_mount, or manually mounted).

(Minor fixes to the documentation by Philip Withnall
<withnall@endlessm.com>.)

https://bugzilla.gnome.org/show_bug.cgi?id=668132
2018-05-16 11:31:42 +01:00
Xavier Claessens
7b8d8835f5 Meson: libintl is a public dependency of glib-2.0
On non-glibc platforms gettext is provided by extra libintl dependency.
We wrongly thought libintl is an internal dependency and applications
needs to explicitly link on it, but turns out that breaks many
applications and with autotools the .pc generated actually has -lintl in
public "Libs:".

https://bugzilla.gnome.org/show_bug.cgi?id=796085
2018-05-15 13:00:44 -04:00
Ondrej Holy
1ec70e713c gio: Fix typo in g_file_info_set_attribute docs
g_file_info_set_attribute mentions %G_ATTRIBUTE_TYPE_INVALID, but no
such value exists. It should be %G_FILE_ATTRIBUTE_TYPE_INVALID.

https://bugzilla.gnome.org/show_bug.cgi?id=796138
2018-05-15 15:54:18 +02:00
David Faure
1c177ce0ab xdgmime: Add better detection for text vs. binary and zero-sized files
This detects zero-sized files to return the special-case
"application/x-zerosize" mime-type, as well as trying to differentiate
unknown file types based on their first 128 bytes of data, so that text
editors can automatically handle unknown text files.

Based on:
https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=5181175d5fdaa3832b0fd094cda0120b1fe92af6
https://cgit.freedesktop.org/xdg/xdgmime/commit/?id=9c5802b8da56187c5c6abaf70042d14b12d832a9

https://bugzilla.gnome.org/show_bug.cgi?id=795544
2018-05-10 11:46:17 +01:00
Xavier Claessens
b6cb22f32b Meson: Do not build tests with nodelete/Bsymbolic-functions
-z nodelete breaks the libresourceplugin module usage in the resources.c
test, which expects to be able to unload it.

Make the Meson build match what the autotools build does: only pass
glib_link_flags to the headline libraries (glib-2.0, gio-2.0,
gobject-2.0, gthread-2.0, gmodule-2.0) and omit it from all other build
targets.

https://bugzilla.gnome.org/show_bug.cgi?id=788771
2018-05-09 12:52:59 +01:00
Matthew Leeds
b437a13a70 gio: Fix a typo in the docs for g_file_is_native() 2018-05-04 18:32:43 -07:00
Iñigo Martínez
5faac84413 gdbus-codegen: Fix header include in the body file
When body file is generated, the header name to be included is
built by using the path passed by `--output` directory. However,
this might not be correct because, if the path includes a
subdirectory, the whole path will be used instead of only the
base name.

Please see:
  https://github.com/mesonbuild/meson/issues/3488
  https://github.com/gnome-mpv/gnome-mpv/issues/305#issuecomment-385056156

https://bugzilla.gnome.org/show_bug.cgi?id=795802
2018-05-04 17:16:10 +01:00
Tomasz Miąsko
9d40f64960 gdesktopappinfo: Mark GDesktopAppInfo constructors as nullable.
GDesktopAppInfo constructors return NULL on error without having
separate **GError parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=795152
2018-05-04 17:13:39 +01:00
Havard Graff
71fba3b3be kqueue/meson: add missing dependency
gioenumtypes needs to be generated:
In file included from ../../../../external/glib/gio/kqueue/gkqueuefilemonitor.c:37:
In file included from ../../../../external/./glib/gio/glocalfilemonitor.h:25:
In file included from ../../../../external/./glib/gio/gunixmounts.h:24:
../../../../external/./glib/gio/gio.h:86:10: fatal error: 'gio/gioenumtypes.h' file not found
#include <gio/gioenumtypes.h>
         ^~~~~~~~~~~~~~~~~~~~

https://bugzilla.gnome.org/show_bug.cgi?id=794325
2018-05-03 00:01:50 +01:00
Georges Basile Stavracas Neto
0f37af7e9b glocalfile: Use g_canonicalize_filename
Drop the local function in favor of the exposed
one.

https://bugzilla.gnome.org/show_bug.cgi?id=111848
2018-04-30 21:54:49 +01:00
Christoph Reiter
fe9457dedd gliststore: Improve the test coverage
https://bugzilla.gnome.org/show_bug.cgi?id=795307
2018-04-30 13:02:41 +02:00
Christoph Reiter
758d7073a9 g_list_store_splice: Add items in the order of the input array and at the given position
It inserted the new items one position after the given one and inserted all new items
at the same position resulting in the items being in the reverse order of the
input array.

It was decided to make these behavioural changes because this function has according to
https://codesearch.debian.net/search?q=g_list_store_splice only one real user (nautilus)
and it didn't do what one would expect from reading the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=795307
2018-04-30 13:02:41 +02:00
Philip Withnall
9b4c50f63d all: Remove trailing newlines from g_message()/g_warning()/g_error()s
All those logging functions already add a newline to any message they
print, so there’s no need to add a trailing newline in the message
passed to them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 16:46:19 +01:00
Philip Withnall
8056b753e5 tests: Fix a free function in the GIO tests
The monitor_path comes from g_file_get_path(), so should be freed with
g_free() rather than free(). This makes no difference because they are
the same function in practice, but using free() is a bit confusing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:36:11 +01:00
Philip Withnall
9365e212f8 More const-correctness fixes
This continues one of the const-correctness fixes from the previous
commit (it needed some more transitive fixes), and reverts another of
them, since it was over-zealous.

This fixes CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/27125.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:35:58 +01:00
Philip Withnall
22cd18500d Fix various const-correctness issues
Spotted when temporarily compiling with -Wwrite-strings. This only goes
a small way towards making the code base -Wwrite-strings–clean. It
introduces no functional changes, and fixes no bugs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-26 15:19:17 +01:00
Florian Müllner
f9f497a702 tests: Add .desktop file for non-existent binary ...
... to test that it is filtered out correctly by
g_desktop_app_info_load_from_keyfile() (but not
g_desktop_app_info_search()).

https://bugzilla.gnome.org/show_bug.cgi?id=795488
2018-04-26 16:03:39 +02:00
Xavier Claessens
d123717947 Meson: Add missing link on libintl in tests
This fix undefined symbol link error when building for non-glibc
platform. Applications must link on libintl, it is not a public
dependency of libglib.

On glibc platforms libintl is a not found dependency and is just ignored
by meson, so it doesn't hurt to always have it.

https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-25 13:56:14 -04:00
Christoph Reiter
97c28f7fe1 ci: fix warnings and enable --werror for the mingw build
Fix various warnings regarding unused variables, duplicated
branches etc by adjusting the ifdeffery and some missing casts.

gnulib triggers -Wduplicated-branches in one of the copied files,
disable as that just makes updating the code harder.

The warning indicating missing features are made none fatal through
pragmas. They still show but don't abort the build.

https://bugzilla.gnome.org/show_bug.cgi?id=793729
2018-04-25 17:23:50 +02:00
Philip Withnall
384a166ed3 gdbus: Clarify types of g-properties-changed signal arguments
Make it a bit more obvious that the changed properties are provided as
an a{sv}.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-25 15:30:46 +01:00
Xavier Claessens
7efd76dd67 struct ip_mreq_source definition is broken on Android NDK <= r16
This fix the build on Android r16 and older, see:
https://issuetracker.google.com/issues/36987220

https://bugzilla.gnome.org/show_bug.cgi?id=740791
2018-04-24 15:00:17 -04:00
Florian Müllner
6343555605 tests: Fix desktop-app-info test
g_desktop_app_info_load_from_keyfile() refuses to load .desktop files
where the executable doesn't exist. Therefore whether or not the .desktop
file added in commit 148995544 is actually considered during tests depends
on /usr/bin/flatpak being installed. This isn't a safe assumption to make,
so use /bin/sh to test filtering of "prefix" commands.

https://bugzilla.gnome.org/show_bug.cgi?id=795488
2018-04-24 18:36:05 +02:00
Florian Müllner
1e2579da2c gdesktopappinfo: Filter out some binary names in search
The executable name can be a useful bit of information to match on in
searches where it differs from the name (for example because the latter
is localised), but will produce surprising results where the real appli-
cation is executed by a shared binary (for example interpretors like
gjs or python, or sandboxes like flatpak).

Address this by adding a blacklist of binary names that are ignored
in search.

https://bugzilla.gnome.org/show_bug.cgi?id=795488
2018-04-24 13:11:00 +02:00
Florian Müllner
1489955444 tests: Use gnome-clocks from flatpak
It's the future (and provides us with a new test case) ...

https://bugzilla.gnome.org/show_bug.cgi?id=795488
2018-04-24 13:11:00 +02:00
Martin Pieuchot
ab179184b8 Reorder operations in _kqsub_cancel() to prevent races.
Removing the event and closing the related file descriptor must be
done first to make sure the kqueue subsystem delete pending events.

The timeout must be disarmed before freeing the directory dependency
list otherwise it might populate it again.

https://bugzilla.gnome.org/show_bug.cgi?id=795193
2018-04-23 20:07:55 +01:00
Philip Withnall
1217b1bc4f codegen: List basenames of input files in generated preamble
This makes it a bit easier for debugging which files were generated from
which introspection XML.

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

https://bugzilla.gnome.org/show_bug.cgi?id=650875
2018-04-23 20:03:53 +01:00
Xavier Claessens
51e5324493 Revert "gsocket: Fix build error on Android"
This was the wrong fix, the real cause is a bug in Android NDK r16:
https://issuetracker.google.com/issues/36987220

This reverts commit 994dd17ee5.
2018-04-20 16:37:35 -04:00
Xavier Claessens
994dd17ee5 gsocket: Fix build error on Android
imr_interface.s_addr is not defined in the HAVE_IP_MREQN case.

https://bugzilla.gnome.org/show_bug.cgi?id=740791
2018-04-20 16:09:43 -04:00
Xavier Claessens
30c2ea4c53 Meson: Use cc.has_type() instead of our own snippet
https://bugzilla.gnome.org/show_bug.cgi?id=740791
2018-04-20 15:47:31 -04:00
Xavier Claessens
5ccd9449fb Tests: gsubprocess: Do not use stdin/stdout variables
https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-20 15:33:31 -04:00
Philip Withnall
29f4eacebe gdbusconnection: Fix a typo in the documentation for close_sync()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-19 16:36:16 +01:00
Philip Withnall
d57f3e0a9b tests: Fix a minor memory leak in the GFileMonitor tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:13:02 +01:00
Philip Withnall
723ac89b0c tests: Add a GFileMonitor test for G_FILE_MONITOR_WATCH_HARD_LINKS
Add a test for monitoring an existing local file, with the
WATCH_HARD_LINKS flag specified. This would previously cause a crash;
now it doesn’t.

This test contains a FIXME where I suspect we should be getting some
additional file change notifications from changes made through the hard
link; this requires further follow up and probably further fixes to our
inotify backend.

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

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:13:02 +01:00
Philip Withnall
3e4e005c96 inotify: Further fixes for hard link monitoring support
This gets the G_FILE_MONITOR_WATCH_HARD_LINKS flag to the state where it
doesn’t cause crashes, and essentially acts as a no-op. It will not yet
actually monitor for changes made via hard links.

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

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:13:02 +01:00
Ryan Lortie
cc5cd5e8ea inotify: fix segfault on watching hard links
The call to _start() fills in the dirname, basename, and filename
arguments according to the following rules:

  dir watches: dirname filled

  file watches: dirname and basename filled

  hardlink: filename filled

This doesn't map to how the current inotify backend works very nicely,
so we need to adjust things a bit when creating our "sub" objects.

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:09:44 +01:00
Philip Withnall
ad50fdbd50 tests: Drop a slightly suspect GResolver test
This test will only work on machines which have IPv6 enabled and have a
local IPv6 interface with ID 1. On machines which don’t (such as AWS
servers, which we run CI tests on), the GResolver tests will fail with
G_RESOLVER_ERROR_INVALID. We can’t differentiate this kind of failure
(where we’d want to skip the test) from an actual failure (where we’d
want to fail the test), so the only other option is to drop this
particular test vector. I don’t think it’s a significant loss.

This is the last fix needed to get our CI tests working reliably on
jenkins.gnome.org.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795234
2018-04-13 17:42:58 +01:00
Philip Withnall
6751424bbe tests: Skip GSocket tests if setting up a server fails
There are various reasons why setting up a server might fail; it
reliably fails on AWS with IPv6 addresses (are we binding to the right
address?). Since we’re trying to test GSocket as a client, skip tests
where that happens.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795234
2018-04-13 16:14:46 +01:00
Philip Withnall
d990f86911 tests: Add more debug output to the network-address test
Trying to diagnose why some of the resolver tests fail on AWS.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795234
2018-04-13 16:14:46 +01:00
Philip Withnall
a90c578952 tests: Lower number of iterations in network-monitor-race
While 333 runs is very likely to reproduce the bug, Milan has previously
reproduced it with as few as 9 runs. Since this test will be run by the
CI machinery quite often, a lower number of runs each CI run will still
probably catch any regressions over time.

This reduces the total test runtime from 33s to 2s.

https://bugzilla.gnome.org/show_bug.cgi?id=793727

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-11 15:45:10 +01:00
Fabrice Fontaine
0beb62f564 gio: fix compilation without F_{S,G}ETPIPE_SZ
Commit a5778ef7c5 broke compilation on
architectures without F_SETPIPE_SZ and F_GETPIPE_SZ such as or1k.
If those variables are undefined, put back previous behavior, buffer
size set to 1024 * 64

Fixes:
 - http://autobuild.buildroot.net/results/398490e07343a931b25ca6ab5c90a75d7a073e9f

(Modified by Philip Withnall <withnall@endlessm.com> to add an
explanatory comment.)

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795133
2018-04-11 15:20:23 +01:00
Milan Crha
ca0add4b8a gnetworkmonitor: Fix use-after-free when using from another thread
When using g_network_monitor_get_default() from another thread, it’s
possible for network-changed events to be processed after an instance of
GNetworkMonitor has been disposed, causing use-after-free problems.

Fix that by moving some of the initialisation into the GInitable.init()
chain, rather than in a main context idle callback.

This includes a unit test which probabilistically reproduces the bug
(but can’t do so deterministically due to it being a race condition).

Commit amended by Philip Withnall <withnall@endlessm.com> before
pushing.

https://bugzilla.gnome.org/show_bug.cgi?id=793727
2018-04-11 15:03:43 +01:00
Philip Withnall
3ba2f8333b glib-compile-schemas: Fix minor memory leaks in error paths
Spotted while running valgrind on gsettings-test, as per the previous
commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-11 11:03:03 +01:00
Christophe Fergeau
fbbad525a5 gsettings: Fix leaks and assertion on range binding failures
When using g_settings_bind(), if a range binding triggers a range check
failure, g_settings_binding_property_changed() will return early, but it
won't cleanup properly causing some leaks. The binding will also still
be marked as 'running', which causes an assertion failure when trying to
free it:
"g_settings_binding_free: assertion failed: (!binding->running)"

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=794805
2018-04-11 10:42:54 +01:00
Ryan Schmidt
9d27ed1d78 gio: Fix build on OS X < 10.9
Commit 170466db accidentally partially reverted commit d1a03bc7.
Reinstate the missing check for OS X 10.9.

The Meson build does not have this problem.

https://bugzilla.gnome.org/show_bug.cgi?id=794380
2018-04-10 12:25:25 +01:00
Simon McVittie
3d50691a30 g_test_dbus_down: Ensure next test does not use old connection
There's a race condition somewhere in GTestDBus that can result in
the next test being started at a time when g_bus_get() would still
return the connection that is in the process of closing. This can
be reproduced reasonably reliably by running the gapplication test
10K times in a loop.

Instead of relying on waiting for the weak reference to be released,
we can force the issue by clearing it.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=768996
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=894677
2018-04-10 11:22:41 +01:00
Philip Withnall
b868cf5864 gio: Add dummy win32 notification backend
This adds a null notification backend implementation for win32, purely
to avoid crashes due to a missing backend when applications use
GNotification. This backend does nothing except print a warning when a
notification is supposed to be emitted.

In future, it can be expanded to use win32 API to present toaster
notifications appropriately.

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

https://bugzilla.gnome.org/show_bug.cgi?id=776583
2018-04-10 10:39:40 +01:00
Iain Lane
ec20cb4402 tests/network-monitor: Always use the dummy proxy resolver
If glib-networking is installed and built with libproxy support, this
test will use it. If a proxy is set in the environment, we might get
correctly told to go through it for certain accesses. However, this isn't
going to work, because the testsuite monkeys with the network monitor to
tell it that all addresses - including the proxy - aren't reachable.

We're trying to check if adding networks to a GNetworkMonitor works in
general. Proxies just get in the way here, so let's use the built in
dummy proxy resolver which just tells us that all URLs are directly
accessible.

https://bugzilla.gnome.org/show_bug.cgi?id=794801
2018-04-10 10:35:45 +01:00
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
Emmanuele Bassi
80d328b3a8 build: Separate the Objective C files into their own helper lib
This avoid polluting the CFLAGS with -xobjective-c.

(Rebased by Philip Withnall <withnall@endlessm.com>.)

https://bugzilla.gnome.org/show_bug.cgi?id=672777
2018-02-15 14:31:36 +00:00
Philip Withnall
66ab836f5a gsubprocess: Fix a critical calling communicate() with no pipes
If calling g_subprocess_communicate() on a GSubprocess with no
stdout/stderr pipe, a critical warning would be emitted from
g_memory_output_stream_steal_as_bytes(), as it would be called on a NULL
output stream.

Fix that, improve the relevant GIR annotations, and expand the unit
tests to cover it (and various other combinations of flags).

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

https://bugzilla.gnome.org/show_bug.cgi?id=793331
2018-02-13 16:27:32 +00:00
Philip Withnall
0cd5127494 build: Fix Meson checks for res_nclose() and res_ndestroy()
The checks wouldn’t compile, and hence would always fail.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793291
2018-02-13 14:18:34 +00:00
Philip Withnall
b716660fab build: Drop fallback checks for libmount versions without pkg-config
Building against libmount installed into a non-default prefix wasn’t
working, as we were using #include <libmount/libmount.h> rather than
the correct #include <libmount.h> — all the mount.pc pkg-config files
set `Cflags: -I${includedir}/libmount`.

Fixing this while retaining the fallback support for versions of
libmount without a pkg-config file would have been tricky (we would need
to work out a suitable -I flag to set in LIBMOUNT_CFLAGS) to still be
able to use the correct #include path). Thankfully, libmount gained
pkg-config support a long time ago, so I think we can safely drop the
fallback code. In particular, Debian Jessie, Ubuntu Trusty, and CentOS 5
all ship a mount.pc file.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793288
2018-02-13 14:17:11 +00:00
Michael Catanzaro
c3c7b52f91 goutputstream: Fix missing call to clear_pending in flush_async
If flush_async is deleted by a child class, then calling
g_output_stream_flush_async would leave the GOutputStream in an invalid
state. I'm not aware of any GOutputStream that would be affected by this
issue, but might as well fix it.

https://bugzilla.gnome.org/show_bug.cgi?id=738277
2018-02-13 08:04:24 -06:00
Will Thompson
5b88ed8caf
gsettings: fix typo in class documentation 2018-02-12 21:28:16 +00:00
Philip Withnall
f8ee429db7 gdbusproxy: Add some missing (transfer) and (nullable) annotations
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773663
2018-02-12 11:33:12 +00:00
Philip Withnall
565d8fa1ee docs: Add Markdown backticks around /dev/null in a few places
This improves the formatting of the documentation ever so slightly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-02-08 16:39:32 +00:00
Philip Withnall
567e5548bb codegen: Fix a typo in g_variant_get_objv()
g_variant_get_objpathv() doesn’t exist. The code actually meant
g_variant_get_objv().

This fixes a leak with `ao`-type properties in generated code.
Previously they wouldn’t be freed; now the container is (correctly)
freed.

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

https://bugzilla.gnome.org/show_bug.cgi?id=770335
2018-02-06 16:00:01 +00:00
Philip Withnall
8e74fbf300 gnetworkaddress: Fix minor memory leak
From commit 99b792fac0.

Spotted by Coverity; CID 1385719.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-02-04 17:33:16 +01:00
Philip Withnall
40be86bb0e gio: Port GThreadedResolver to use res_nquery() to fix thread-safety
res_query() uses global state in the form of the struct __res_state
which contains the contents of resolv.conf (and other things). On Linux,
this state seems to be thread-local, so there is no problem. On OS X,
however, it is not, and hence multiple res_query() calls from parallel
threads will compete and return bogus results.

The fix for this is to use res_nquery(), introduced in BIND 8.2, which
takes an explicit state argument. This allows us to manually store the
state thread-locally. If res_nquery() isn’t available, we fall back to
res_query(). It should be available on OS X though. As a data point,
it’s available on Fedora 27.

There’s a slight complication in the fact that OS X requires the state
to be freed using res_ndestroy() rather than res_nclose(). Linux uses
res_nclose().

(See, for example, the NetBSD man page:
https://www.unix.com/man-page/netbsd/3/res_ninit/. The Linux one is
incomplete and not so useful:
http://man7.org/linux/man-pages/man3/resolver.3.html.)

The new code will call res_ninit() once per res_nquery() task. This is
not optimal, but no worse than before — since res_query() was being
called in a worker thread, on Linux, it would implicitly initialise the
thread-local struct __res_state when it was called. We’ve essentially
just made that explicit. In practical terms, this means a
stat("/etc/resolv.conf") call per res_nquery() task.

In future, we could improve this by using an explicit thread pool with
some manually-created worker threads, each of which initialises a struct
__res_state on spawning, and only updates it on receiving
the #GResolver::reload signal.

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

https://bugzilla.gnome.org/show_bug.cgi?id=792050
2018-02-02 18:05:27 +01:00
Allison Lortie
235f4958a9 gsettings: remove redundancy in 'list-recursive'
Some projects use child schemas in an odd way: they link children which
already have their path pre-defined.  This causes the child schema (and
its keys) to be printed out twice:

 - once because it is, itself, a non-relocatable schema

 - once, as a recursion from its parent

We can avoid this by not recursing into child schemas that are
non-relocatable (on the assumption that they will be enumerated
elsewhere).

https://bugzilla.gnome.org/show_bug.cgi?id=723003
2018-02-02 14:41:00 +01:00
Philip Withnall
07f75f6cc2 gdbusmessage: Make a translatable message translatable with plurals
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=658713
2018-02-02 10:07:12 +01:00
Philip Withnall
5ed77c1104 gdatainputstream: Deprecate read_until() in favour of read_upto()
g_data_input_stream_read_upto() was introduced in 2.26; now it’s GLib
2.56, we can probably deprecate the old versions (since the handling of
consuming the stop character differs between the sync and async versions
of it).

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

https://bugzilla.gnome.org/show_bug.cgi?id=584284
2018-02-02 10:05:55 +01:00
Bastien Nocera
e889fb2a7f resolver: Return early if URI is invalid
https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:58:29 +00:00
Bastien Nocera
99b792fac0 networkaddress: Add early sanity check to _g_uri_parse_authority()
Check whether the URI is valid ASCII before trying to parse it. This
should catch broken URIs early.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:58:28 +00:00
Bastien Nocera
5f2c20e88b networkaddress: Return an error from _g_uri_parse_authority()
So that errors can be propagated if necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:58:28 +00:00
Bastien Nocera
88366621ee GSimpleProxyResolver: Add test case for broken hostname
https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:58:28 +00:00
Bastien Nocera
132cf9a9d4 resolver: Return error looking up services on invalid hostnames
Make g_resolver_lookup_service() and
g_resolver_lookup_service_async() error out when invalid hostnames are
passed.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:58:28 +00:00
Bastien Nocera
cb8c919952 simpleproxyresolver: Don't crash on invalid hostname
Check for g_hostname_to_ascii() failure, rather than crashing when
checking whether an invalid hostname should go through the proxy.

The HTTP library should report the error about the invalid hostname
once we actually try to connect to it.

https://bugzilla.gnome.org/show_bug.cgi?id=772989
2018-02-01 14:17:50 +00:00
Ignacio Casal Quinteiro
1a99154898 gpollableoutputstream: document side effects of WOULD_BLOCK on D/TLS
If the underlying transport is D/TLS the same data and data length
is required to be sent on the next iteration when a WOULD_BLOCK
happens. This is due to the fact that gnutls or openssl keep
an internal state for the data.

https://bugzilla.gnome.org/show_bug.cgi?id=792862
2018-01-31 22:37:18 +00:00
Philip Withnall
4752d72a60 gdbusaddress: Disable proxy support for D-Bus addresses
See the discussion in the bug report: with proxy support enabled, a
proxy resolver is created. Doing that will load all the GIO modules, and
typically at least one of them will try to use GDBus during
initialisation, which will cause a deadlock.

Using a TCP address with GDBusAddress is still supported, but accessing
it over a proxy is not.

Document this.

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

https://bugzilla.gnome.org/show_bug.cgi?id=792499
2018-01-31 22:25:02 +00:00
Iñigo Martínez
93042e0052 gdbus-codegen: Fix issue with docbook generation
In cases where gdbus-codegen is used only for docbook generation,
the execution stops with the following error message:

  `Using --header or --body requires --output`

This is because it was assumed that, in addition to the docbook
generation, the header or source code were always generated.

This patch fixes this, and the header or source code generation
is not mandatory, so the docbook can be generated separately.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-31 22:12:51 +00:00
Ondrej Holy
7e0d42e3dc gunixmounts: Skip accumulated events from file monitor
Skip accumulated events from file monitor which we are not able to handle
in a real time instead of emitting mounts_changed signal several times.
This should behave equally to GIOChannel based monitoring. See Bug 792235.

https://bugzilla.gnome.org/show_bug.cgi?id=793006
2018-01-30 15:31:13 +01:00
Bastien Nocera
801accf746 GNotification: Don't ignore set_urgent()'s argument
set_urgent() would behave is if @urgent was always true. The regression
was introduced in commit 01098e34c1

https://bugzilla.gnome.org/show_bug.cgi?id=792777
2018-01-23 14:24:12 +00:00
Philip Withnall
cea72036e3 gnotification: Add missing deprecation tag to set_urgent()
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=792777
2018-01-22 11:24:47 +00:00
Philip Withnall
3787e42932 gio: Rename GNetworkMonitorWindows to GWin32NetworkMonitor
This makes it more consistent with other GWin32* objects. No functional
changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-18 10:12:26 +00:00
Philip Withnall
ba976f13b6 gio: Rename gnetworkmonitorwindows to gwin32networkmonitor
This makes it more consistent with the other win32 objects in GIO. This
commit just renames the files; a follow-up commit will rename the
GObject.

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

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-17 12:59:51 +00:00
Jan-Michael Brummer
f9aacf3952 GNetworkMonitorWindows: Add IPv4/IPv6 network monitor backend for windows
Added a Windows backend to GNetworkMonitor, using NotifyRouteChange2()
(available on Vista and later). It marshals the route change callbacks
to the thread-specific default main context the GNetworkMonitor was
constructed in.

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-17 12:31:26 +00:00
Colin Walters
4808a957b5 GFile: Add g_file_peek_path()
This is a variant of g_file_get_path() which returns a const string to
the caller, rather than transferring ownership.

I've been carrying `gs_file_get_path_cached()` in libgsystem and it
has seen a lot of use in the ostree and flatpak codebases.  There are
probably others too.

I think language bindings like Python/Gjs could also use this to avoid
an extra malloc (i.e. we could transparently replace
`g_file_get_path()` with `g_file_peek_path()`.

(Originally by Colin Walters. Tweaked by Philip Withnall to update to
2.56, change the function name and drop the locking.)

https://bugzilla.gnome.org/show_bug.cgi?id=767976
2018-01-15 18:26:56 +00:00
Iñigo Martínez
261cb8ea86 gdbus-codegen: Set source coding to utf-8
Some of the recent changes introduced UTF-8 characters which made
gdbus-codegen to crash when using Python 2.

Following PEP 263, the utf-8 coding comment has been used.

PEP: https://www.python.org/dev/peps/pep-0263/
BUG: https://bugzilla.gnome.org/show_bug.cgi?id=791015

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2018-01-15 17:04:31 +01:00
Iñigo Martínez
e4d68c7b3e gdbus-codegen: Support for separate C header and code generation
gdbus-codegen's options only allow a simultaneous header and source
code generation.

A `--header` and `--body` options have been added along with the
`--output` option which allow separate C header and code
generation.

These options cannot be used in addition to the old options such
as `--generate-c-code`, `--generate-docbook` or
`--output-directory`.

These options have also been added to gdbus-codegen's documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:11:17 +01:00
Iñigo Martínez
6c3af1cdda gdbus-codegen: Remove unnecessary parameters from the constructor
The `outdir` and `docbook` parameters are passed to the
`DocbookCodeGenerator` constructor, but these parameters are only
used at docbook generation, which is optional.

The parameters have been removed from the class creation and added
to the `generate` method, where they are actually being used.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:10:12 +01:00
Iñigo Martínez
22772acff8 gdbus-codegen: Split C header and code generation
The class that generated both C header and code has been split into
two classes. These clases are now specialized on creating the header
or the body code.

All parameters that do not belong to each class have also been
deleted, so only the necessary parameters still remain. These also
includes the header and code file descriptors, leaving only the
corresponding file descriptor necessary for each class.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:07:07 +01:00
Iñigo Martínez
a66f2f80e0 gdbus-codegen: Split C header and code generation functions
The generation of the C header and code preambles have been split
in order to be able to generate both files separately in the future.

The functions for generating preambles and postambles have also been
renamed following the function names used in the glib-genmarshal
rewrite, so that they stay consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:06:01 +01:00
Iñigo Martínez
c658d03b76 gdbus-codegen: Add support for pragma inclusion guard
The #pragma once is widely supported preprocessor directive that can
be used instead of include guards.

This adds support for using optionally this directive instead of
include guards.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:05:26 +01:00
Iñigo Martínez
e59bce3c74 gdbus-codegen: Move from optparse to argparse
The optparse module is deprecated since version 2.7 and the
development continues with the argparse.

The code has been moved from optparse to argparse when parsing
command-line options. This has also led to the deprecation of the
`--xml-files`, and positional arguments should be used instead.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:03:39 +01:00
Iñigo Martínez
dcc1fe09d0 gdbus-codegen: Use Color's print_* methods
`glib-genmarshal` and `glib-mkenums` use a `Color` class which
implements a number of print_* methods to print colored messages
to the standard error output.

In order to be consistent with those programs' output,
`gdbus-codegen` has also started using that same class and methods.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-15 16:03:03 +01:00
Philip Withnall
e430541378 docs: Remove XML-style comments from documentation strings
gtk-doc doesn’t support them any more since it was ported to Markdown,
so they end up appearing in the generated documentation, which isn’t
great.

Mostly, they were used to split up things invisibly, which we can do in
other ways.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-12 15:29:29 +00:00
Philip Withnall
d3b07453ab docs: Add a link to the Wikipedia page on TOCTTOU races
Try and make it a bit more obvious that g_file_query_exists() is
generally A Bad Idea.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-12 12:10:16 +00:00
Philip Withnall
373bf178b6 docs: Fix syntax in GDBusInterfaceSkeleton documentation
gtk-doc was mis-parsing the combination of ` and :: and truncating some
of the documentation. Avoid that by using the D-Bus style of separating
interface and signal names using a dot.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-11 16:03:05 +00:00
Philip Withnall
9c638bbf04 docs: Fix a typo in the GDBusProxy documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-11 15:31:17 +00:00
Bastien Nocera
181d1c3052 GNetworkMonitor: Rename "network-changed" signal argument
Because the argument being called "available" and the property being
called "network-available" is confusing.

Also remove the details of what that value means, as it's already
described in the property, and duplicating the explanation makes it look
like it might have a different meaning.

https://bugzilla.gnome.org/show_bug.cgi?id=792370
2018-01-09 16:24:27 +00:00
Philip Withnall
c4ad10fede docs: Mention D-Bus reply types are tuples
The g_dbus_connection_call() documentation doesn’t make it clear that
the reply type is always a tuple.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-09 15:17:02 +00:00
Simon McVittie
2685a533af gdbus-threading test: Allow even longer for test_method_calls_in_thread
This should take 4 seconds + overhead, but on a slow or heavily
loaded system, there's no guarantee that it won't take significantly
longer.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=792364
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884660
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-09 13:10:38 +00:00
Iñigo Martínez
a3d223d0e9 gdbus-codegen: Split license string
The license string which is embedded in the C header and body
preambles has been moved to a global variable. This way it can be
reused in both sections.

https://bugzilla.gnome.org/show_bug.cgi?id=791015
2018-01-09 13:13:08 +01:00
Michael Catanzaro
045b805199 tlsclientconnection: Deprecate ssl3 property and functions
I originally planned to introduce a new property and functions to
replace these, with the same behavior but less-confusing names. But that
might not be the best approach in the long run. Instead, let's just
deprecate them without replacement.

TLS 1.2 intolerance is no longer a thing in the wild, and no known
GTlsBackend supports TLS 1.3 yet. But you might need to use this
property in the future, even though it's deprecated, if your
GTlsBackend has added support for TLS 1.3 and you need to talk to a
server that is TLS 1.3 intolerant.

Independently of all that, these APIs simply no longer do what their
names suggest, so deprecation is sensible regardless.

https://bugzilla.gnome.org/show_bug.cgi?id=792217
2018-01-08 19:17:01 -06:00
Michael Catanzaro
9e5254ebce tlsclientconnection: Update use-ssl3 documentation
The property documentation correctly indicates how this code works
nowadays, but the function documentation is obsolete and misleading.
Update it.

https://bugzilla.gnome.org/show_bug.cgi?id=792217
2018-01-08 19:17:01 -06:00
Florian Müllner
a55bfeee41 gdesktopappinfo: Add g_desktop_app_info_get_locale_string()
Custom desktop file fields may be translated, but there is currently
no non-hacky way to look up the localized value; fill get gap with
a small wrapper around g_key_file_get_locale_string().

https://bugzilla.gnome.org/show_bug.cgi?id=779413
2018-01-08 16:28:34 +01:00
Philip Withnall
84350cb566 gopenuriportal: Fix mismatched types in callback
The source object for this asynchronous operation is the GXdpOpenURI,
not a GDBusConnection. This was causing crashes in method calls on the
connection, unsurprisingly.

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

https://bugzilla.gnome.org/show_bug.cgi?id=791720
2018-01-08 15:16:19 +00:00
Philip Withnall
eba53aa07e build: Add missing test GSchema XML file to dist list
This was introduced in bug #742997, but not added to the Makefile.am, so
it’s missing from tarballs.

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

https://bugzilla.gnome.org/show_bug.cgi?id=792322
2018-01-08 12:05:21 +00:00
Philip Withnall
d8fe926ba4 Fix various strict aliasing problems with sockaddr
Fix various strict aliasing problems caused by casting between (struct
sockaddr *) and (struct sockaddr_storage *): the correct code here is to
keep the two in a union.

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

https://bugzilla.gnome.org/show_bug.cgi?id=791622
2018-01-08 11:50:26 +00:00
Simon McVittie
7f3bfcb891 cancellable: Don't assert if finalization races with cancellation
Commit 281e3010 narrowed the race between GCancellable::cancelled and
GCancellableSource's finalize(), but did not prevent it: there was
nothing to stop cancellation from occurring after the refcount drops
to 0, but before g_source_unref_internal() bumps it back up to 1 to
run finalize().

GCancellable cannot be expected to detect that situation, because the
only way it has to detect last-unref is finalize(), but in that
situation finalize() hasn't happened yet.

Instead of detecting last-unref, relax the precondition a little
to make it detect finalization: priv is only poisoned (set to NULL)
after the finalize() function has been called, so we can assume that
GCancellable has already seen finalize() by then.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=791754
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884654
2018-01-05 20:42:06 +00:00
Philip Withnall
32b2ab9492 docs: Fix some odd grammar in the GDBusError documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-05 19:29:35 +00:00
Arnaud Bonatti
6d009bc56a Add ‘gsettings list-schemas --print-paths’ option
Prints next to the name of non-relocatable schemas their paths.

https://bugzilla.gnome.org/show_bug.cgi?id=792064
2018-01-05 13:01:03 +00:00
Christoph Reiter
cf93b27ceb meson: fix static build under Windows
Properly define GLIB/GOBJECT_STATIC_COMPILATION when static build is enabled.
Use library() instead of shared_library() to allow selecting static builds.

https://bugzilla.gnome.org/show_bug.cgi?id=784995
2018-01-04 22:21:40 +01:00
Christoph Reiter
aa7c5cbdcb meson: build Windows resource files
configure_file() forces utf-8 atm but .rc files are not utf-8.
To work around the issue just remove the only non-ASCII char.

https://bugzilla.gnome.org/show_bug.cgi?id=784995
2018-01-04 22:19:30 +01:00
Xavier Claessens
7f69b828fc GIOModule: Use unique names for load/unload symbols
GIO modules should include their name into their exported symbols to
make them unique. This avoids symbol clash when building modules
statically.

extract_name() function is copied from GStreamer which recently
switched to the same symbol naming scheme.

https://bugzilla.gnome.org/show_bug.cgi?id=684282
2018-01-04 11:01:40 -05:00
howetuft
0e22d19a11 Bug-790839 GApplication command line --help enhancements
In order to enrich information displayed by GApplication command line
handling when --help is invoked, 3 new methods are proposed:
. g_application_set_option_context_parameter_string
. g_application_set_option_context_summary
. g_application_set_option_context_description
Those methods interact with the GApplication's internal GOptionContext
which is created for command line parsing in g_application_parse_command_line.
(please refer to the GOptionContext class for more information about option
context, parameter string, summary and description.)

To illustrate the 3 methods, an example is provided:
. gapplication-example-cmdline4.c
2018-01-03 11:08:37 +00:00
Daniel Boles
b441c21a09 gdbus-test-codegen: Cast to void* to printf "%p"
to suppress a compiler error with stricter warnings enabled (GCC):

gdbus-test-codegen.c: In function ‘on_handle_get_self’:
gdbus-test-codegen.c:403:26: error: format ‘%p’ expects argument of type
 ‘void *’, but argument 2 has type ‘GThread * {aka struct _GThread *}’
 [-Werror=format=]
   s = g_strdup_printf ("%p", g_thread_self ());

https://bugzilla.gnome.org/show_bug.cgi?id=792099
2018-01-01 17:23:23 +00:00
Christian Hergert
8213793f34 socketlistener: fix event signature in vfunc
The GSocketListener::event signal has a type of GSocketListenerEvent,
which is an enum. However, the vfunc signature had a pointer, with
different sizing requirements. Given the alignment and prompostion
of some systems, you may still get the same call-site layout, but
that is not guaranteed.

This fixes the parameter to have the proper enumeration.

https://bugzilla.gnome.org/show_bug.cgi?id=791906
2017-12-25 00:12:06 -08:00
Xavier Claessens
62c4768423 Meson: Add missing options and conform to naming guidelines
https://bugzilla.gnome.org/show_bug.cgi?id=790837
2017-12-19 14:56:11 -05:00
Ting-Wei Lan
8e91aaed79 glocalfile: Update the list of Linux filesystem magic numbers
Add filesystem magic numbers found in statfs(2) manual page. Filesystem
magic numbers that are not available from the manual page are copied
from Linux source code.

configfs is found in fs/configfs/mount.c, macro CONFIGFS_MAGIC.
fusectl is found in fs/fuse/control.c, macro FUSE_CTL_SUPER_MAGIC.
rpc_pipefs is found in net/sunrpc/rpc_pipe.c, macro RPCAUTH_GSSMAGIC.

https://bugzilla.gnome.org/show_bug.cgi?id=754634
2017-12-19 18:51:00 +08:00
Simon McVittie
8fef0a9cd3 gmenumodel test: Wait for the expected events to happen
Previously, we waited an arbitrary 100ms or 200ms and then asserted
that the events had happened, but that might fail if the machine is
slow or heavily loaded.

We still wait for an arbitrary time for negative tests (asserting
that no more signals are received) because we don't have any way
to do better here.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884661

https://bugzilla.gnome.org/show_bug.cgi?id=791744
2017-12-18 18:56:35 +00:00
Simon McVittie
ea159a9e1a gmenumodel test: If something goes wrong, don't wait forever
I'm about to add some loops that would otherwise wait indefinitely.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884661

https://bugzilla.gnome.org/show_bug.cgi?id=791744
2017-12-18 18:56:35 +00:00
Havard Graff
5f83cd3add meson.build: make the android-check reflect the autotools one
In autotools this same check reads:

AS_IF([test $glib_native_android != yes]

with glib_native_android being defined as:

case $host in
  *android*)
    glib_native_android="yes"
    ;;
  *)
    glib_native_android="no"
    ;;
esac

This is needed to be able to compile on OSX.

https://bugzilla.gnome.org/show_bug.cgi?id=791460

Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>
2017-12-14 16:21:46 +05:30
Havard Graff
db7c1180b3 meson: add libintl when linking gio-tests on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=791460
2017-12-14 16:21:46 +05:30
Jens Georg
f5804275af gdbus-codegen: Clarify license of generated code
https://bugzilla.gnome.org/show_bug.cgi?id=780893
2017-12-13 14:09:05 +00:00
Friedrich Beckmann
6d0210240a MacOS: gosxcontenttype.c consider generic icon names also
This patch considers generic icon names also when icon names
are searched based on content type. Without this fix only
non-generic icon names are found. This results in no icons
for pdf and jpeg files in the file selection dialog.
This is discussed in

https://bugzilla.gnome.org/show_bug.cgi?id=788936
2017-12-11 11:40:14 +00:00
Mario Sanchez Prada
637a298960 gio/tests/appinfo: New test for launch with "appId-less" applications
New test to make sure we exercise the code paths in gdesktopappinfo.c
that get triggered when g_desktop_app_info_launch_uris_with_spawn()
is used (i.e. unknown app ID, no session bus), both for when either
a single URI or multiple ones are expected by the application.

https://bugzilla.gnome.org/show_bug.cgi?id=791337
2017-12-08 13:47:23 +00:00
Mario Sanchez Prada
d501bd0dbe gdesktopappinfo: Gracefully handle NULL URIs when passed to expand_macro()
If an application calls g_app_info_launch_uris() with a GList that includes
NULL values in some of its data members, and GIO ends up internally calling
g_desktop_app_info_launch_uris_with_spawn() for whatever reason (e.g. no
D-Bus session available), expand_macro() will crash due to the invalid data.

As this is considered a programmer error, use g_return_val_if_fail() in those
situations to prevent the crash from happening, but printing a warning anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=791337
2017-12-08 13:47:23 +00:00
Mario Sanchez Prada
fbed9c8b85 gdesktopappinfo: Pass a copy of the URIs list to expand_application_parameters()
This list will be modified in-place when calling expand_macro(), so pass a copy
of it instead the original pointer, that is supposed to be an input parameter
only for g_desktop_app_info_launch_uris_with_spawn().

https://bugzilla.gnome.org/show_bug.cgi?id=791337
2017-12-08 13:47:23 +00:00
Friedrich Beckmann
018b997dd2 MacOS: fix content type check vs. mime check to show folder icons
In MacOS the file selection dialog does not show folder icons.
With this fix the folder icons are shown. The bug is described
in:

https://bugzilla.gnome.org/show_bug.cgi?id=788936

This bug fix is only partial, because this fix is only the
last resort when no mime information is available.
2017-12-08 11:10:27 +00:00
Philip Withnall
62dece198b gio: Fix querying of thumbnail attributes other than thumbnail::path
The thumbnail attributes would previously only be set if thumbnail::path
was included in the query — so querying for just thumbnail::is-valid
would return no results.

This fixes the behaviour of
    gio info -a thumbnail::is-valid ./some-file.png
vs
    gio info -a thumbnail ./some-file.png

The first command would previously list nothing. The second would
previously list a thumbnail::path and thumbnail::is-valid.

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

https://bugzilla.gnome.org/show_bug.cgi?id=791325
2017-12-07 13:03:18 +00:00
Arnaud Bonatti
2ebc78ae71 gio: Remove stray ‘<’ from gschema.dtd
The mathematical operator was making the DTD unusable.
Also, min and max can be equal with current parser.

https://bugzilla.gnome.org/show_bug.cgi?id=791267
2017-12-06 10:33:52 +00:00
Arnaud Bonatti
0d59878bce Fix gschema.dtd regarding flags
https://bugzilla.gnome.org/show_bug.cgi?id=791235
2017-12-05 12:31:49 +00:00
Christian Hergert
f44472e715 gobject: fix typecasts via g_object_ref
Now that g_object_ref() propagates the parameter type to the
return value, we need to cast to ensure the result is warning
free.

https://bugzilla.gnome.org/show_bug.cgi?id=790697
2017-12-04 11:42:58 +00:00
Philip Withnall
c26aab36db gio: Fix a minor indentation problem
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2017-12-04 10:38:01 +00:00
Michael Catanzaro
18f4583653 gdbusconnection: Fix link in documentation 2017-12-03 19:22:58 -06:00
Philip Withnall
36f7440bb7 goutputstream: Fix pre-condition
Spotted by Izak van Langevelde.

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

https://bugzilla.gnome.org/show_bug.cgi?id=791036
2017-12-01 10:02:21 +00:00
Philip Withnall
06719a86b2 docs: Drop unnecessary <!-- -->s from gtk-doc comments
Putting a <!-- --> in plural<!-- -->s was an old hack used to fix
linking the symbol with gtk-doc when gtk-doc didn’t know about plural
forms. gtk-doc does now know about plural forms, so the hack can be
removed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-11-29 17:50:27 +00:00
Philip Withnall
a2a4a10299 tests: Fix some minor memory leaks in gdbus-test-codegen
It’s not entirely leak-free, but it’s better than before.

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

https://bugzilla.gnome.org/show_bug.cgi?id=741167
2017-11-28 14:28:50 +00:00
Philip Withnall
37d9b0c699 gdbusutils: Fix a memory leak in g_dbus_gvalue_to_gvariant()
g_variant_get_normal_form() doesn’t necessarily return a floating
GVariant, so we have to take, rather than sink, the ref.

This fixes a lot of leaks with gdbus-codegen-generated code.

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

https://bugzilla.gnome.org/show_bug.cgi?id=741167
2017-11-28 14:28:50 +00:00
Tim Waugh
d35d9b7911 codegen: fix array out-param annotations
When using gdbus-codegen to produce generated code for a method with
an out parameter with a signature like 'as', make sure to include
an "(array)" annotation for that parameter.

(Reworked by Philip Withnall to improve code formatting.)

https://bugzilla.gnome.org/show_bug.cgi?id=741167
2017-11-28 14:28:49 +00:00
Philip Withnall
2a0db6d868 inotify: Add missing commas
These were accidentally omitted from commit
748bb24985. My fault.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-11-28 14:25:34 +00:00
Philip Withnall
e644bfa37e gio: Add some casts for printf() formatting statbufs on Solaris
Apparently Solaris defines statbuf fields as long when Linux doesn’t, in
some cases. Cast down to the type expected by the printf() format
placeholder.

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

https://bugzilla.gnome.org/show_bug.cgi?id=749652
2017-11-28 14:17:09 +00:00
Philip Withnall
b16d7fc1a7 gmountoperation: Add missing (array) annotations
Two of the vfuncs in GMountOperation need some annotations for their
element types and array sizes, otherwise g-ir-scanner comes up with
nonsense output.

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

https://bugzilla.gnome.org/show_bug.cgi?id=773980
2017-11-28 14:14:19 +00:00
Philip Withnall
181eb900d5 gdesktopappinfo: Downgrade a warning to a debug message
Bug #786580 triggered this warning to show up in the appinfo tests if
run on a machine where no terminal except xterm is installed (for
example, a build machine). Since we didn’t warn before if xterm but no
other terminals were installed, it seems reasonable to downgrade the
warning to a debug message.

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

https://bugzilla.gnome.org/show_bug.cgi?id=790914
2017-11-28 14:12:40 +00:00
Philip Withnall
748bb24985 inotify: Don’t propagate unrecognised events to GLocalFileMonitor
If we can’t convert the inotify event mask into a GFileMonitorEvent enum
value, don’t propagate it to GLocalFileMonitor, since it hits an
assertion failure in that case.

This should no longer be possible since the previous commit to ignore
IN_Q_OVERFLOW events, but we might as well change this just in case
other bugs crop up in event mask handling.

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

https://bugzilla.gnome.org/show_bug.cgi?id=776147
2017-11-28 13:55:34 +00:00
Philip Withnall
9853842c53 inotify: Ignore IN_Q_OVERFLOW events
There’s not much we can do about them, and if they go unhandled, they
can propagate through to g_file_monitor_source_handle_event() and cause
assertion failures due to not mapping to a GFileMonitorEvent.

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

https://bugzilla.gnome.org/show_bug.cgi?id=776147
2017-11-28 13:55:34 +00:00
Philip Withnall
76072a2dde kqueue: Fix invalid emission of G_FILE_MONITOR_EVENT_MOVED event
That event is deprecated, and the kqueue backend can’t provide enough
information to go alongside the event (i.e. the name of the new file).
Use G_FILE_MONITOR_EVENT_DELETED instead.

Quite disappointed in the kqueue documentation for this: I cannot find a
single piece of documentation or example about how NOTE_RENAME is
supposed to communicate the new name of the file.

If it turns out that this is possible, the code can be amended again in
future. At least now it doesn’t abort.

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

https://bugzilla.gnome.org/show_bug.cgi?id=776147
2017-11-28 13:55:34 +00:00
Carlos Garcia Campos
7dcc09e586 gproxyresolverportal: do not connect to session bus when not under flatpak
While gio module extension is loaded a new GProxyResolverPortal is
created to query whether it's supported. We always return FALSE when not
aunder flatpak, so we don't need to connect to the session bus in that
case. Add a helper ensure_resolver_proxy() that returns TRUE when the
proxy is created and use it in is_supported() instead of creating the
proxy unconditionally in the instance initialization.

https://bugzilla.gnome.org/show_bug.cgi?id=790894
2017-11-27 12:36:03 +01:00
Nirbheek Chauhan
7a9d92702e meson: Create gio-unix and gio-win32 internal deps
These are useful when using glib as a subproject and you want to use
gio-unix-2.0 or gio-win32-2.0.
2017-11-24 12:40:43 +05:30
Nirbheek Chauhan
bd22bb9898 meson: Use files() for gio sources and headers
This allows them to be fetched with subproject().get_variable(). Needed
for generating Gio-2.0.gir in the gobject-introspection meson port.
2017-11-23 23:03:57 +05:30
Daniel Macks
deeacce18a Do not load systemwide giomodules during self-test
$libdir/gio/modules/*.so on the live build machine are supplied by
third parties, so we should not look there while testing ourselves.

https://bugzilla.gnome.org/show_bug.cgi?id=780309
2017-11-20 10:23:23 +00:00
Daniel Macks
0b10c41a04 Git should ignore generated config.py file
gio/gdbus-2.0/codegen/config.py is generated by ./configure from
gio/gdbus-2.0/codegen/config.py.in

https://bugzilla.gnome.org/show_bug.cgi?id=790588
2017-11-20 10:17:01 +00:00
Philip Withnall
9ab0073321 glocalfileinfo: Fix a leak on an error handling path
Spotted by Clang static analysis, thanks to Leslie Zhai.

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

https://bugzilla.gnome.org/show_bug.cgi?id=777075
2017-11-17 14:39:55 +00:00
Philip Withnall
63c07f9b63 codegen: Change (allow-none) annotations to (nullable)
(nullable) has been around for a while now.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-11-17 11:42:48 +00:00
Daiki Ueno
c71098ddab tests/gmenumodel: Add test cases using peer-to-peer D-Bus connection
https://bugzilla.gnome.org/show_bug.cgi?id=720380
2017-11-17 11:28:43 +00:00
Daiki Ueno
f29065c315 GMenuExporter: Allow NULL bus name for peer-to-peer connection
https://bugzilla.gnome.org/show_bug.cgi?id=720380
2017-11-17 11:28:43 +00:00
Daiki Ueno
d37af2bd04 GDBusActionGroup: Allow NULL bus name for peer-to-peer connection
https://bugzilla.gnome.org/show_bug.cgi?id=720380
2017-11-17 11:28:43 +00:00
Daiki Ueno
e8a09b3f85 GDBusMenuModel: Allow NULL bus name for peer-to-peer connection
https://bugzilla.gnome.org/show_bug.cgi?id=720380
2017-11-17 11:28:43 +00:00
Philip Withnall
d4f07f21fb glocalfile: Fix leak of FS type on some platforms
fstype is a const char*, and is passed to
g_file_info_set_attribute_string(), which takes a copy of it. There’s no
need to g_strdup() the FS type from various statfs/statvfs buffers
beforehand, given that the buffers are valid for the duration of this
function.

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

https://bugzilla.gnome.org/show_bug.cgi?id=679347
2017-11-15 13:08:11 +00:00
Christian Hergert
ed78f30c5e file: add tests for g_file_load_bytes()
This adds a test for both g_file_load_bytes() and the
asynchronous form g_file_load_bytes_async().

https://bugzilla.gnome.org/show_bug.cgi?id=790272
2017-11-15 04:10:23 -08:00
Christian Hergert
2227918dfd file: add g_file_load_bytes()
This adds g_file_load_bytes() to make it more convenient to
load the contents of a GFile as GBytes.

It includes a special casing for gresources to increase the
chances that the GBytes directly references the embedded data
instead of copying to the heap.

https://bugzilla.gnome.org/show_bug.cgi?id=790272
2017-11-15 03:52:41 -08:00
Christian Hergert
5464461e4c gresource: avoid allocations in enumerate_children()
In the vast majority of cases, we can avoid temporary
allocations for paths in g_resources_enumerate_children().

In the case we need to add a suffix "/", we can usually just
build the path on the stack. In other cases, we can completely
avoid the strdup, which appears to only have been added for
readability. If the path is really long, we fallback to doing
what we did before, and use g_strconcat().

In the case of Builder, this saved 5.3mb of temporary
allocations in the process of showing the first application
window.

https://bugzilla.gnome.org/show_bug.cgi?id=790275
2017-11-15 03:24:29 -08:00
Christian Hergert
38ffcd298c gresourcefile: simplify path canonicalization
Previously, the path canonicalization for resources had liberal use of
strlen() and memmove() while walking through the path. This patch avoids
any secondary strlen() and removes all use of memmove().

A single allocation is created up front as we should only ever need one
additional byte more than then length of the incoming path string.

To keep the implementation readable, the mechanics are kept in external
functions. memrchr() was not used due to its lack of portability.

This is faster in every test case I've tested. Paths that contain
relative ../ have the most speedup.

https://bugzilla.gnome.org/show_bug.cgi?id=790310
2017-11-14 15:13:44 -08:00
Sebastian Dröge
7b60708204 GResource – Create an internal copy of the GBytes if it is not pointer aligned
https://bugzilla.gnome.org/show_bug.cgi?id=790030
2017-11-14 10:39:45 +02:00
Sebastian Dröge
3c9c01e3ce GResource – Add note to documentation that the memory must be at least pointer aligned
https://bugzilla.gnome.org/show_bug.cgi?id=790030
2017-11-14 10:19:58 +02:00
Stefan Sauer
c68f66c19e docs: fix 'emphasis' tag
There is no 'em' tag in docbook. Use 'emphasis'. This would also require
to enable --xml-mode in MKDB_OPTIONS, but that requires more cleanups.
2017-11-12 21:04:30 +01:00
Stefan Sauer
2812219adb docs: add missing '*' chars at start of doc-comments 2017-11-12 16:36:16 +01:00
Philip Withnall
1897e66dce build: Drop data-to-c.pl in favour of data-to-c.py
The Python version was added for the Meson build, but we might as well
use it from autotools too, since it does exactly the same thing as the
Perl version (modulo not including a trailing linebreak, but that
doesn’t matter).

Works fine with Python 2.7 or Python 3.

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

https://bugzilla.gnome.org/show_bug.cgi?id=790147
2017-11-10 11:47:57 +00:00
Christian Kellner
b9b7a1d039 gio-tool: fix inverted logic in monitor tool
The tool should refuse to work if none of the locations to watch
are set, not if *any* of them are unset.

https://bugzilla.gnome.org/show_bug.cgi?id=790093
2017-11-09 10:47:14 +01:00
Cosimo Cecchi
44d6052584 gfile: add g_file_new_build_filename()
This is a convenience C API that combines g_build_filename() with
g_file_new_for_path().

https://bugzilla.gnome.org/show_bug.cgi?id=788488
2017-11-07 08:25:28 -08:00
Philip Withnall
8e8f4e6486 docs: Fix various minor syntax errors in gtk-doc comments
This will fix a few broken links in the documentation, and shut up a
load of gtk-doc warnings (but certainly not all of them).

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

https://bugzilla.gnome.org/show_bug.cgi?id=790015
2017-11-07 14:51:12 +00:00
Philip Withnall
249d74fcf6 docs: Make argument names in GAppInfo consistent
This fixes a mismatch between some of the gtk-doc comments and reality.

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

https://bugzilla.gnome.org/show_bug.cgi?id=790015
2017-11-07 14:50:23 +00:00
Ondrej Holy
796599a705 gio-tool: Do not alter uris before use
Uris may be altered by the following code, which breaks xdg-open:
file = g_file_new_for_commandline_arg (arg[i])
uri = g_file_get_uri (file);

Examples of possible uri changes:
mailto:email -> mailto:///email
magnet:?xt=urn:hash -> magnet:///?xt=urn:hash
ssh://user@host -> sftp://user@host

This patch causes that uris aren't preprocessed for locations with
scheme, however absolute and relative paths are still preprocessed.

https://bugzilla.gnome.org/show_bug.cgi?id=779182
2017-11-07 13:46:56 +01:00
Colin Walters
cb8bfa758f gdbus-codegen: Call abspath() earlier
The previous change from https://bugzilla.gnome.org/show_bug.cgi?id=786785
didn't actually work (for me at least) in the `/bin/gdbus-codegen` case
as the relative `/bin/../share` path works, but then `os.path.abspath()`
breaks it (as it's not doing `realpath()`, and let's not go there).

Fix this by doing the `abspath` first.

Downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1507661

https://bugzilla.gnome.org/show_bug.cgi?id=789723
2017-11-06 11:57:52 +00:00
Rico Tzschichholz
df66b25301 GSeekable: Fix g_seekable_truncate invoker reference
https://bugzilla.gnome.org/show_bug.cgi?id=573251
2017-11-04 20:05:37 +01:00
Daniel Macks
d88d90c3c8 Exec=true (seach via PATH) instead of hardcoding /bin/true
...otherwise this .desktop is omitted on platforms that have it
elsewhere.

https://bugzilla.gnome.org/show_bug.cgi?id=731705
2017-11-03 20:16:52 +00:00
Uwe Helm
5448ef5326 gio: Add FS magic number for FUSE
https://bugzilla.gnome.org/show_bug.cgi?id=740826
2017-11-03 19:50:19 +00:00
Tomas Kotal
ea2901abf8 gio: GPollFileMonitor is not cleaning up correctly
https://bugzilla.gnome.org/show_bug.cgi?id=789820
2017-11-03 14:07:57 +00:00
Jiří Techet
9bcd7800a1 gio: Eliminate warnings in cstring conversion on OS X
create_cstr_from_cfstring_with_fallback() is allowed to be called when str == NULL
but create_cstr_from_cfstring() isn't which leads to warnings in the console.
Fix this by adding NULL checks into create_cstr_from_cfstring_with_fallback().

https://bugzilla.gnome.org/show_bug.cgi?id=788936
2017-11-03 12:04:33 +00:00
Jiří Techet
6acaca8831 gio: Show icons based on file's mime type on OS X
The patch basically just grabs the implementation of g_content_type_get_icon_internal()
from gcontenttype.c - the only difference is that it first converts UTI to MIME using
g_content_type_get_mime_type() and at the end frees this temporary MIME type.

https://bugzilla.gnome.org/show_bug.cgi?id=788936
2017-11-03 12:04:33 +00:00
Colin Walters
96ebcee8c4 Build with old libmount too
Downstream: https://bugzilla.redhat.com/show_bug.cgi?id=1508056

This is an easy change, and lets us build with RHEL7's libmount.

See also cee57a0268
2017-11-01 14:22:18 -04:00
Will Thompson
41112ef00d GSeekable: improve g_seekable_[can_]truncate docs
I was not born next to a PDP-11, either, but I think this is marginally more informative!

https://bugzilla.gnome.org/show_bug.cgi?id=573251
2017-11-01 15:29:22 +00:00
Tom Schoonjans
663a5cc95f gio/gasynchelper.c: fix cast from pointer to smaller int type on win64
https://bugzilla.gnome.org/show_bug.cgi?id=777310
2017-11-01 12:54:14 +00:00
Руслан Ижбулатов
53bd6a359f W32: Add a stat() implementation for private use
This commit adds new W32-only functions to gstdio.c,
and a new header file, gstdioprivate.h.
These functions are:
g_win32_stat_utf8()
g_win32_lstat_utf8()
g_win32_fstat()
and they fill a private structure, GWin32PrivateStat,
which has all the fields that normal stat has, as well as some
extras.

These functions are then used throughout glib and gio to get better
data about the system. Specifically:
* Full, 64-bit size, guaranteed (g_stat() is forced to use 32-bit st_size)
* Full, 64-bit file identifier (st_ino is 0 when normal stat() is used, and still is)
* W32 File attributes (which stat() doesn't report); in particular, this allows
  symlinks to be correctly identified
* Full, 64-bit time, guaranteed (g_stat() uses 32-bit st_*time on 32-bit Windows)
* Allocated file size (as a W32 replacement for the missing st_blocks)

st_mode remains unchanged (thus, no S_ISLNK), so when these are given back to
glib users (via g_stat(), for example, which is now implemented by calling g_win32_stat_utf8),
this field does not contain anything unexpected.

g_lstat() now calls g_win32_lstat_utf8(), which works on symlinks the way it's supposed to.

Also adds the g_win32_readlink_utf8() function, which behaves like readlink()
(including its inability to return 0-terminated strings and inability to say how large
the output buffer should be; these limitations are purely for compatibility with
existing glib code).

Thus, symlink support should now be much better, although far from being complete.

A new W32-only test in gio/tests/file.c highlights the following features:
* allocated size
* 64-bit time
* unique file IDs

https://bugzilla.gnome.org/show_bug.cgi?id=788180
2017-11-01 12:46:38 +00:00
Christoph Reiter
fed574a0c8 introspection: Add more filename type annotations for strings which can contain filenames
This continues the changes done in https://bugzilla.gnome.org/show_bug.cgi?id=767245

This makes it possible to pass Python path types as process arguments and env vars
in PyGObject and and makes it clear that the values are not strictly utf-8 and need
to be validated/converted first.

https://bugzilla.gnome.org/show_bug.cgi?id=788863
2017-10-26 18:51:51 +02:00
Debarshi Ray
7339a09376 docs: Mention the idiomatic way of invoking a GAsyncReadyCallback
The GAsyncResult documentation didn't specify the context in which the
GAsyncReadyCallback is expected to be invoked. Since asynchronous
operations can be implemented in various ways involving GSources,
threads and coroutines, it is useful to mention what the standard
expections are.

Unfortunately, since this was left undefined for so long, we can only
phrase it as a suggestion, and not as a hard requirement.

https://bugzilla.gnome.org/show_bug.cgi?id=783825
2017-10-26 14:08:42 +02:00
Debarshi Ray
09d936c528 docs: Explain how GAsyncReadyCallbacks are, and should be, invoked
https://bugzilla.gnome.org/show_bug.cgi?id=783825
2017-10-26 14:08:42 +02:00
Debarshi Ray
61ea1e7ca4 docs: Don't be vague about where GTask dispatches the result
https://bugzilla.gnome.org/show_bug.cgi?id=783825
2017-10-26 13:48:39 +02:00
Debarshi Ray
3c5b59ddca docs: Clarify the thread-default GMainContext where the result is sent
https://bugzilla.gnome.org/show_bug.cgi?id=783825
2017-10-26 13:48:39 +02:00
Philip Withnall
3eacec1587 Use hash tables as sets in various places
Where we were already treating GHashTables as sets, modify them to use
the set-specific APIs g_hash_table_add() and g_hash_table_contains(), to
make that usage more obvious and less prone to being broken.

Heavily based on patches by Garrett Regier <garrettregier@gmail.com>.

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

https://bugzilla.gnome.org/show_bug.cgi?id=749371
2017-10-26 12:27:17 +01:00
Stef Walter
0f82ff12ea gdbus-proxy: Fix erroneous timeout during following tests
Modified by Philip Withnall to amend a second instance in the same
file.

https://bugzilla.gnome.org/show_bug.cgi?id=711809
2017-10-26 12:01:05 +01:00
Philip Withnall
767296db9c gio: Add autoptr declarations for GUnixMountEntry and GUnixMountPoint
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788927
2017-10-26 00:19:23 +01:00
Philip Withnall
1e4221a3f7 gio: Add API for identifying system FS types and device paths
This is needed by gnome-control-center and gnome-settings-daemon; it
makes existing checks from gunixmounts.c public.

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

https://bugzilla.gnome.org/show_bug.cgi?id=788927
2017-10-26 00:19:23 +01:00
Michael Catanzaro
4b07869462 socket: actually remove fd from poll when socket is closed
In my previous patch, I failed to call g_source_remove_unix_fd() in
order to actually stop polling the fd of the closed socket.

The test did not catch this, because the test only checks that the right
source callback is dispatched properly. I don't know how to test this.

https://bugzilla.gnome.org/show_bug.cgi?id=723655
2017-10-25 09:36:07 -05:00
Michael Catanzaro
c5202bc5e9 Add socket postmortem test
Checks that after a GSocket is closed, a source created off it
with g_socket_create_source() will dispatch exactly once with
G_IO_NVAL.

Based on a patch by Mikhail Zabaluev

https://bugzilla.gnome.org/show_bug.cgi?id=723655
2017-10-24 09:02:02 -05:00
Michael Catanzaro
f99045fd03 socket: Don't poll the socket fd after close
This prevents polling on file descriptors that are no longer in use
or have been reused for something else.

Based on a patch by Mikhail Zabaluev

https://bugzilla.gnome.org/show_bug.cgi?id=723655
2017-10-24 09:02:02 -05:00
Emmanuele Bassi
5c13bf9bcf build: Use subdir-objects with Autotools
We're eventually going to drop Autotools, but in the meantime we should
probably use idiomatic options and reduce warnings.

GLib is pretty much already safe for subdir-objects to be enabled,
except in the GIO tests, where the build references files that are
generated in a different level. For that, we can use the same solution
employed by GTK+, and link the appropriate file in the right
sub-directory.

https://bugzilla.gnome.org/show_bug.cgi?id=788989
2017-10-24 13:30:41 +01:00
Xiang Fan
3d4fb44653 gsettings: make g_settings_bind() documentation clearer
https://bugzilla.gnome.org/show_bug.cgi?id=789245
2017-10-23 12:20:02 +01:00
Friedrich Beckmann
37c0610b4d MacOS: gosxappinfo.c Fix some memory leaks. Fix failure condition.
Ensure that the debug call won't crash if create_cstr_from_cfstring
returns NULL, fix the leak of that CFArrayRef, and make explicit the
failure condition of LSFindApplicationForInfo.

https://bugzilla.gnome.org/show_bug.cgi?id=788936
2017-10-17 14:10:31 +01:00
Friedrich Beckmann
2bd423c54c MacOS: create_cstr_from_cfstring uses safe conversion - use CFStringGetCString
During testing with gdk-pixbuf I noticed failures during content type
to mime conversion. The root reason was the unsafe conversion used
in create_cstr_from_cfstring. The problem was addressed in commit
c60226e0a1 but that was reverted. I noticed the commit only
when I had fixed the problem. In addition I added a test to check
the content type to mime conversion on MacOS. This problem is
discussed in Bug #788936.

See: https://bugzilla.gnome.org/show_bug.cgi?id=788936
2017-10-17 14:10:31 +01:00
Julien Isorce
ea725a6414 gio: add g_socket_join_multicast_group_ssm (IGMPv3 SSM)
It adds support for source-specific multicast IGMPv3.

Allow receiving data only from a specified source when joining
a multicast group.

g_socket_join_multicast_group_ssm can be called multiple times
to allow receiving data from more than one source.

Support IPv4 and IPv6.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=740791
2017-10-16 11:14:57 +01:00
Friedrich Beckmann
e55efa35e3 OSX: Use xdgmime system to guess content type from data
Closes: Bug #788401

The problem is described here:

https://bugzilla.gnome.org/show_bug.cgi?id=788401

This patch introduces the use of the xdgmime system to guess
the content type from data. So you can guess for example the
type public.svg-image from the file content of a svg file.
This patch only applies to MacOS. A test for the regression
is also included.
2017-10-14 09:11:01 +01:00
Philip Withnall
13c6d9fedf Revert "[MacOS] Fallback to CFStringGetCSTring if CFStringGetCStringPtr fails."
This reverts commit c60226e0a1.

Pushed without review. This should be reviewed on bug #788936 first.
Several issues with the patch:
 • Takes the string length unnecessarily early.
 • Calls CFRelease(str) before g_strdup(cstr) which could lead to
   use-after-free.
 • Code style issues.
 • Don’t want to encourage pushing patches without review.
2017-10-14 09:04:43 +01:00
John Ralls
c60226e0a1 [MacOS] Fallback to CFStringGetCSTring if CFStringGetCStringPtr fails. 2017-10-13 14:04:02 -07:00
Philip Withnall
0d69462f14 gunixmounts: Update list of virtual file systems to ignore
Synchronise it with the list in gnome-settings-daemon, which has seen
more recent updates than this one.

https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/housekeeping/gsd-disk-space-helper.c

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

https://bugzilla.gnome.org/show_bug.cgi?id=788880
2017-10-13 11:01:30 +01:00
Rico Tzschichholz
65e443da65 gio: Mark callback_data of GFileReadMoreCallback as closure
In conjunction with 77fbc10da6

https://bugzilla.gnome.org/show_bug.cgi?id=629347
2017-10-12 09:20:17 +01:00
Beniamino Galvani
aeecd81dd1 gio: fix race condition in GDBusObjectManagerClient
priv->map_object_path_to_object_proxy must be protected to avoid
concurrent access by multiple threads. Move the hash table insertion
into the critical section.

https://bugzilla.gnome.org/show_bug.cgi?id=788368
2017-10-11 16:36:20 +01:00
Rico Tzschichholz
1fb56be6ab gio: Mark g_task_get_source_object as nullable
In conjunction with ca4fe5942a

Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 17:14:11 +02:00
Philip Withnall
3d8296940a tests: Fix case of a string comparison
Fixup to commit 12e32e96a3.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 14:05:21 +01:00
Simon McVittie
331f73c26d gio/tests/gdbus-proxy: sleep longer when testing that we time out
On slow ARM machines doing parallel builds, there's no guarantee that
we'll get scheduled in a window between (100ms|250ms) and 500ms.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=769674
2017-10-11 13:32:48 +01:00
Simon McVittie
7d5c738dba gio/tests/file: increase an arbitrary timeout
On slow ARM machines doing parallel builds, there's no guarantee that
we'll get through this in 5 seconds.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=769674
2017-10-11 13:32:41 +01:00
Florian Müllner
77fbc10da6 introspection: Add more annotations for GFile
Add annotations fixing warnings in GFile.

https://bugzilla.gnome.org/show_bug.cgi?id=629347
2017-10-11 13:26:15 +01:00
Christian Dywan
0ef7174e74 Document that pre-unmount may not be emitted
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=636210
2017-10-11 13:18:49 +01:00
Daniel Macks
b8ccbd9a3c Fix variable-scoping to avoid declaring on platforms where not used
"len" is only used by some platforms' implementations (as controlled
by various autoconf/#ifdef tokens) and only in a small codeblock in
those cases, but was declared based on a looser #ifdef heuristic and
in a larger scope. The result is an unused-variable warning when built
on some platforms. Move declaration to the local codeblocks that use
the variable, which also restricts it to the narrower set of platforms
where those codeblocks are used.

https://bugzilla.gnome.org/show_bug.cgi?id=689323
2017-10-11 13:12:36 +01:00
Philip Withnall
e34884e364 gsettingsschema: Add a missing (nullable) annotation
Spotted as part of https://bugzilla.gnome.org/show_bug.cgi?id=725014.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 13:09:53 +01:00
Philip Withnall
5876cdff25 gsettingsschema: Fix some incorrect whitespace
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 13:09:40 +01:00
Philip Withnall
ee1d38ce64 docs: Fix an incorrect function name in GSettings documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 13:09:15 +01:00
Evan Nemerson
ca4fe5942a gio: mark the GAsyncResult source_object as nullable
https://bugzilla.gnome.org/show_bug.cgi?id=740223
2017-10-11 13:00:43 +01:00
Руслан Ижбулатов
4a77eb16ce Replace all instances of ssize_t with gssize
ssize_t is supported widely, but not universally, so use gssize instead.
Currently only one piece of code actually *needs* this change to be compilable
with MSVC, the rest are mostly in *nix parts of the code, but these are changed
too, for symmetry.

https://bugzilla.gnome.org/show_bug.cgi?id=788180
2017-10-11 12:56:11 +01:00
Руслан Ижбулатов
6abdc06da6 W32: Bump target NT version to 0x601 (7 or newer)
Also remove now-unnecessary if_nametoindex() implementation
(the HAVE_IF_NAMETOINDEX configure check didn't work correctly, it turned out),
which prevents glib from building. if_nametoindex() is available in lphlpapi since
Vista[1], so we don't need a compatibility function for it anymore, as Windows 7
is the new minimally-required version.

[1] https://msdn.microsoft.com/en-us/library/windows/desktop/bb408409(v=vs.85).aspx

https://bugzilla.gnome.org/show_bug.cgi?id=788180
2017-10-11 12:29:55 +01:00
Nirbheek Chauhan
b444ae0de2 meson: Improve gdbus-codegen custom target dependencies
Ensure that the custom targets that use gdbus-codegen get rebuilt when
any of the gdbus-codegen files are changed.

https://bugzilla.gnome.org/show_bug.cgi?id=752239
2017-10-11 16:55:39 +05:30
Philip Withnall
faf9440908 gdbus-tool: Add tab completion support to gdbus emit
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788594
2017-10-11 12:18:14 +01:00
Philip Withnall
51e91e35c1 gdbus-tool: Fix some invalid indentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788594
2017-10-11 12:18:14 +01:00
Philip Withnall
b3acf58779 gdbus-tool: Fix tab-completion for non-message-bus connections
• `gdbus monitor` can’t work at all for non-message-bus connections,
   since it can’t subscribe to signals.
 • Other tab completions for names depend on the connection being a
   message bus connection, but we still need to print `--dest` (etc.)
   when tab completing them, even if we can’t print a list of
   available names.

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

https://bugzilla.gnome.org/show_bug.cgi?id=788594
2017-10-11 12:18:14 +01:00
Philip Withnall
181b58c46d build: Fix build with srcdir ≠ builddir
Broken by commit a71f51dece. My fault for
not reviewing thoroughly enough.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-11 10:52:44 +01:00
Cor-Paul Bezemer
a71f51dece build: Add gdbus-codegen files as dependencies in generated code rule
So gdbus-daemon-generated.[ch] get regenerated appropriately if any of
them change.

https://bugzilla.gnome.org/show_bug.cgi?id=752239
2017-10-11 10:33:45 +01:00
Maks Naumov
12e32e96a3 Don't skip invalid enum values in schemas
Signed-off-by: Maks Naumov <maksqwe1@ukr.net>

https://bugzilla.gnome.org/show_bug.cgi?id=742997
2017-10-11 10:22:23 +01:00
Jan Alexander Steffens (heftig)
30b25a6fd9 meson: Fix permissions of installed scripts
configure_file preserves the attributes, so the templates need to be
executable for the (installed) outputs to be executable.

https://bugzilla.gnome.org/show_bug.cgi?id=787671
2017-10-11 09:49:26 +01:00
Nirbheek Chauhan
b9f2ea4235 gdbus-codegen: Don't assume bindir and datadir share prefix
This assumption breaks when, for instance:

* Called as /bin/gdbus-codegen
* Installed on Windows in a directory that is not `bin/`

For such cases, we cannot make any assumptions about the directory
structure, and must hard-code the datadir.

https://bugzilla.gnome.org/show_bug.cgi?id=786785
2017-10-11 09:48:38 +01:00
grindhold
5b64522fcb socket: fix typo in get_remote_address docs
fixed the following typo:
"remove address" → "remote address"

https://bugzilla.gnome.org/show_bug.cgi?id=788766
2017-10-10 11:31:49 +01:00
Chun-wei Fan
2c6c03290f gio: Fix gio-tool-open.c on Windows/Cocoa
Commit 7384e37 broke builds on these platforms as *NIX-only APIs are
being used unconditionally.  Fix the build by building these portions
when not on Windows or Cocoa.

https://bugzilla.gnome.org/show_bug.cgi?id=780296
2017-10-09 09:10:48 +08:00
Philip Withnall
0a10f7375f glocalfileinfo: Use g_strcmp0() for some comparisons which might be NULL
The return value from g_get_user_special_dir() might be NULL. Safest to
use g_strcmp0() uniformly everywhere.

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

https://bugzilla.gnome.org/show_bug.cgi?id=661442
2017-10-06 11:17:40 +01:00
Ondrej Holy
1508db2f66 gio: Add hack to close up dbus-daemon race
If gio open exits before the program it starts fully activates, then
the dbus-daemon may avoid doing the activating method call.

This commit works around the problem by pinging the activated application,
and waiting for a reply.

Same workaround is used in gtk-launch and was used in gvfs-open before
it was replaced by gio open.

https://bugzilla.gnome.org/show_bug.cgi?id=780296
2017-10-05 16:19:31 +02:00
Jiro Matsuzawa
acea147cbc gsettings: Suppress error messages of completion
https://bugzilla.gnome.org/show_bug.cgi?id=695681
2017-10-05 14:41:24 +01:00
Philip Withnall
55905db86a gfile: Fix typo in documentation for g_file_set_attribute()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-10-05 13:46:41 +01:00
Philip Withnall
b0cbd21b25 glib-compile-resources: Fix leak of a GHashTable
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=788138
2017-10-02 15:30:23 +01:00
Ondrej Holy
f6fa90fb0d gunixmounts: Fix mount points generation
Commit 53ed180 improved mtab processing, however, also introduced bug
in code obtaining mount points. mtab was used by mistake also for
g_unix_mount_points_get implementation, which is obviously wrong and
fstab has to be used instead...

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-10-02 12:19:51 +02:00
Philip Withnall
330e6911b5 goutputstream: Add missing (optional) annotations to bytes_written args
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-09-27 10:31:34 +01:00
Nelson Benítez León
c1a31c3aaa gio/gunixmounts.c: Don't use mtime to monitor mounts on /proc/
Fix get_mounts_timestamp() to not use a stat'ed mtime for /proc/ files.
Instead, use mount_poller_time if /proc/ watch is running, or otherwise
return a new generated timestamp to always assume mounts-changed, which
is safer than previous behaviour of always assuming mounts-not-changed
(as mtime never changes for /proc/ files when queried from the same
process).

We say it's safer because allows caches depending on:

g_unix_mounts_get(&time_read)
g_unix_mounts_changed_since()

to drop possibly outdated/duplicated values, as that was the case for the
GIO mounts cache used in gio/glocalfile.c which provides mount info for
g_file_query_filesystem_info() call, as described in below referenced bug.

This fix complements related commit bd9e266e11

https://bugzilla.gnome.org/show_bug.cgi?id=787731
2017-09-22 20:28:44 +05:00
Nelson Benítez León
32a9b88b20 gio/tests: Add testcase for bug 787731
Add testcase for function g_file_query_filesystem_info()
reporting outdated info for "filesystem::readonly" attribute
when said attribute was different in a previous mounted
partition in the same device (as GIO maintains a mounts cache
per 'st_dev' stat() member).

To trigger a mount operation, testcase uses program 'bindfs'
instead of 'mount --bind' as bindfs does not require root
privileges. And 'fusermount -u' command is used to unmount said
bindfs mount.

As a reference in Fedora, 'bindfs' is installed from 'bindfs'
package and 'fusermount' from 'fuse' package (this one is installed
by default as being part of 'System Tools' group).

The test creates a directory with a file in it, then mounts it
readonly over another directory (the mountpoint), it then checks
that g_file_query_filesystem_info() for the file in it indeed reports
"filesystem::readonly" as TRUE. Then unmounts and mounts again this
time rw (not readonly), it then checks again if g_file_query_filesystem_info()
is reporting "filesystem::readonly" as TRUE, if that's the case, it
confirms the bug by opening said file in write mode.

Testcase is only added for Unix builds.

https://bugzilla.gnome.org/show_bug.cgi?id=787731
2017-09-22 20:28:44 +05:00
Philip Withnall
09796b3ccc Partially revert "gio: Add missing (array length) annotations"
This reverts commit 8028494335.

Adding (array length=…) to a gchar* parameter causes the GIR file to
contain an array of strings, rather than an array of characters. While
we fix GIR, revert those changes.

Some of the other changes in the file (which have an explicit
(element-type) already) are fine.

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

https://bugzilla.gnome.org/show_bug.cgi?id=765063
2017-09-21 12:05:06 +01:00
Alisa Maas
8028494335 gio: Add missing (array length) annotations
https://bugzilla.gnome.org/show_bug.cgi?id=765063
2017-09-21 11:08:12 +01:00
Robert Ancell
db2ae64636 Fix comment/docs grammar: incase -> in case 2017-09-15 13:50:41 +12:00
Chun-wei Fan
a7a6449f4d meson: Install items according to their relevance
The m4 and bash completion items are usable and relevant
depending on the host system's configuration.  So, we check for the
presence of the programs that these items depend on, and only install
them when those programs are found.

For the Valgrind suppression files, we don't install them on Windows as
Valgrind is currently not supported on Windows.

Als fix the path where the GDB helpers are installed, as the path is
incorrectly constructed.

This will fix the "install" stage when building on Visual Studio at
least as there are some post-install steps that are related to them,
which will make use of these programs.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-09-14 16:02:03 +08:00
Philip Withnall
5e55a4e243 gtlsbackend: Default to indicating no support for DTLS in GTlsBackend
I’m unsure what the original reasoning for returning TRUE by default
from supports_dtls was, but it is not backwards-compatible. If a
pre-existing GTlsBackend implementation never implements the
supports_dtls vfunc, the supports_dtls() method will magically return
TRUE rather than FALSE.

Since any backend which does implement DTLS should be implementing the
supports_dtls vfunc (and no DTLS-supporting backends have actually been
merged yet; see bug #697908), it seems safer to make this slight API
break in the name of backwards compatibility than to leave it as
returning TRUE incorrectly.

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

https://bugzilla.gnome.org/show_bug.cgi?id=787485
2017-09-13 17:38:42 +01:00
Sam Thursfield
bb26bc29e3 Make GListModelInterface::get_item usable from GObject Introspection bindings
Language bindings have so far been unable to implement the GListModel
interface because the ::get_item virtual function returns a
non-bindable type (gpointer). The `gpointer` type gets translated into
`void` by G-I meaning that get_item() implementations can't return any
items.

We can set the return type of the get_item() vfunc explicitly to
GObject, which fixes the issue.

This patch also removes the existing (type GObject) annotation on
g_list_model_get_item(), which is necessary because if its return type
matches that of the get_item() vfunc, G-I connects the two and
propagates the 'skip' annotation from one to the other resulting in the
get_item() vfunc being hidden. There's no API break here because the
'skip' annotation makes g_list_model_get_item() invisible to G-I users
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=787271
2017-09-12 12:32:20 +01:00
Philip Chimento
7b9503a4f8 docs: Clarify relationship of quit() to hold count
Calling g_application_quit() ignores the hold count; this patch adds a
warning to the documentation about other code having a hold on the
application and expecting it to exist.

https://bugzilla.gnome.org/show_bug.cgi?id=737278
2017-09-11 22:26:04 +01:00
Daniel Macks
b8f9c08a09 Avoid setting unused variables (-Wself-assign)
Setting a variable and then assigning it to itself avoids
-Wunused-but-set-variable but this specific trick is now caught by
-Wself-assign. Instead, actually use the value or don't bother
assigning it at all:

gdbusauthmechanismsha1.c: #ifdef a var decl to match its actual use use
gdbusauthmechanismsha1.c: call g_ascii_strtoll() in void context

https://bugzilla.gnome.org/show_bug.cgi?id=745723
2017-09-11 22:18:42 +01:00
Daniel Macks
190f64a0fb Avoid setting unused variables (-Wself-assign)
Setting a variable and then assigning it to itself avoids
-Wunused-but-set-variable but this specific trick is now caught by
-Wself-assign. Instead, actually use the value or don't bother
assigning it at all:

gdbusauth.c: call g_data_input_stream_read_byte() in void context
gdbusauthmechanismsha1.c: value is actually used
gdbusmessage.c: use consistent preprocessor-token protection
gthreadedresolver.c: skip over bytes in data blob
httpd.c: do something useful with the value

https://bugzilla.gnome.org/show_bug.cgi?id=745723
2017-09-11 22:14:18 +01:00
Emmanuele Bassi
5d9ccf162e gio: Annotate GDBusObjectManagerClient signal appropriately
https://bugzilla.gnome.org/show_bug.cgi?id=756009
2017-09-11 21:31:13 +01:00
Philip Withnall
1275b94fe7 gsettings: Fix copy-paste error in property documentation
This should fix the introspection binding for that property too.

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

https://bugzilla.gnome.org/show_bug.cgi?id=656502
2017-09-11 21:28:40 +01:00
Mikhail Zabaluev
e5db8ec787 Skip g_subprocess_launcher_set_child_setup() in introspection
It's not likely that the runtime of a bound language using the
introspection supports running in a process forked by a foreign
library, so that a closure programmed in that language would work
safely.

Any programming environment supporting that would probably have
its own advanced facilities for process spawning, or be able
to access the GLib spawning APIs via raw C bindings (still
represented in the introspection, (skip) only adds a flag)
and do any low-level preparatory dances as necessary for the
forked runtime.

Note that there are other APIs making use of GSpawnChildSetupFunc,
but they are usable with the closure nullified, and we cannot annotate
the closure parameters away because that would break the annotated API
for bindings; accordingly to bug #738176 comment #3, the current bindings'
users are expected to pass null.
2017-09-11 21:07:09 +01:00
Mikhail Zabaluev
48cf1d32c6 Fix up closure annotations for GSpawnChildSetupFunc
https://bugzilla.gnome.org/show_bug.cgi?id=738176
2017-09-11 21:07:08 +01:00
Alberto Ruiz
df8350b316 GSubprocessLauncher: add (transfer none) annotation
https://bugzilla.gnome.org/show_bug.cgi?id=753521
2017-09-11 20:23:13 +01:00
Philip Withnall
52dd98475c gtlsbackend: Add missing preconditions for DTLS virtual methods
Make it a bit more obvious when the DTLS methods aren’t implemented by a
particular TLS backend; return an invalid type rather than crashing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=752240
2017-09-11 19:15:15 +01:00
Cosimo Cecchi
88a39670e7 GSettingsBackend: use a GWeakRef during dispatch
Instead of a full reference, which causes problems for clients that
expect a GSettings instance to stop firing signals once they drop the
last reference.

https://bugzilla.gnome.org/show_bug.cgi?id=780861
2017-09-08 09:29:18 -07:00
Chris Lamb
e5eaca5492 gio-querymodules: Make the output reproducible
Whilst working on the Reproducible Builds effort [0], we noticed that
queryimmodules generates non-reproducible output as it iterates over the
filesystem without sorting.

Patch attached.

 [0] https://reproducible-builds.org/

Signed-off-by: Chris Lamb <lamby@debian.org>

https://bugzilla.gnome.org/show_bug.cgi?id=786983
2017-09-08 15:20:27 +01:00
Daniel Boles
b1b00517cf GApplication: Fix required # of elements in docs
The reality, as shown by our tests, is that only 2 elements are needed.
2017-09-06 21:44:25 +01:00
Cj Malone
926db3174a gdesktopappinfo.c: Drop disregarded xterm check
https://bugzilla.gnome.org/show_bug.cgi?id=786580
2017-08-23 23:55:43 +01:00
Philip Withnall
73eee8d64e tests: Fix some leaks and double-frees in the GSubprocess tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Will Thompson
65a95a5a2d gio: failing cases for subprocess cancellable bug
https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Philip Withnall
8f86d312d8 gio: Fix double-callback on cancellation with GSubprocess
See bug #786456 for a detailed analysis of the situation which can cause
this (in summary, if a g_subprocess_wait_async() call is cancelled on a
GSubprocess which is already known to be dead).

The problem was that the GCancellable callback handler was
unconditionally returning a result for the GTask for
g_subprocess_wait_async(), even if that GTask had already returned a
result and the callback was being invoked after the GTask had been
removed from the pending_waits list.

Fix that by checking whether the GTask is still in the pending_waits
list before returning a result for it.

Thanks to Will Thompson for some very useful unit tests which reproduce
this (which will be pushed in the following commit).

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

https://bugzilla.gnome.org/show_bug.cgi?id=786456
2017-08-23 11:37:32 +01:00
Philip Withnall
a60359aee2 tests: Add temporary working directory for monitor test
Similarly to the previous commit, move the temporary directory for the
monitor test from $(cwd) to the system temporary directory.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Philip Withnall
0f5b523fac tests: Add temporary working directory for appmonitor test
Rather than creating a temporary directory in the current directory
(typically the builddir), then never deleting it; create one in the
system /tmp directory, and clean it up properly afterwards.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Philip Withnall
3ce00b29ec tests: Fix leak in appmonitor test
Spotted by Daniel Macks.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785260
2017-08-23 11:26:57 +01:00
Ondrej Holy
087525b62b gio-tool: Use print_file_error correctly
Use print_file_error where an error relates to that file and vice versa.

https://bugzilla.gnome.org/show_bug.cgi?id=786463
2017-08-18 14:46:23 +02:00
Ondrej Holy
78fa67e70c gio-tool-save: Use g_output_stream_write_all instead of while
Simplify the read-write copy code and use g_output_stream_write_all
instead of while and g_output_stream_write.

https://bugzilla.gnome.org/show_bug.cgi?id=786462
2017-08-18 14:46:23 +02:00
Ondrej Holy
1cce5dda18 gfile: Use g_output_stream_write_all instead of while
Simplify the read-write copy code and use g_output_stream_write_all
instead of while and g_output_stream_write.

https://bugzilla.gnome.org/show_bug.cgi?id=786462
2017-08-18 14:46:23 +02:00
Ondrej Holy
c7f2a7e431 gio-tool-save: Prevent overwriting error
The following warning is shown, when both g_output_stream_write and
g_output_stream_close fail:
"GError set over the top of a previous GError or uninitialized memory."

Let's clear the error after use.

https://bugzilla.gnome.org/show_bug.cgi?id=786463
2017-08-18 14:46:23 +02:00
Ondrej Holy
37cddec0ee gio-tool: Unify buffer sizes
Recently, buffer size for copying has been increased in order to improve
performance:
https://bugzilla.gnome.org/show_bug.cgi?id=773823

Let's do the same for gio-tool-save and gio-tool-cat.

https://bugzilla.gnome.org/show_bug.cgi?id=786460
2017-08-18 14:46:23 +02:00
Chun-wei Fan
54aee1f627 Meson: Set _WIN32_WINNT to 0x0601 (Windows 7)
We want to set _WIN32_WINNT so that functions will be properly found in
the headers, to target the NT6.1+ (Windows 7+) APIs.

Also improve the checks for if_nametoindex() and if_indextoname() on
Windows as they are supported in Windows Vista+, but they have
to be checked by linking against iphlpapi.lib (or -liphlpapi).  On other
platforms, they are still checked as they were before.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-08-17 23:40:35 +08:00
Chun-wei Fan
32d6a76b98 build: Use Meson's find_library() for MSVC builds as needed
Some of the dependencies' build systems for Visual Studio do not provide a
pkg-config file upon build, so we use find_library() for them when the
corresponding pkg-config files are not found during Visual Studio builds,
so that one will not need to make up pkg-config files for them, which
could be error-prone.  These .lib names match the names that are built
with the officially supported build system that is used by their
respective Visual Studio support.

For ZLib, this will make gio-2.0.pc reflect on the zlib .lib based on
what is found, or whether we use the fallback/bundled ZLib, when we
don't have a pkg-config file for ZLib on MSVC.  We still need to depend
on Meson to be updated to put the correct link argument for linking ZLib
in the pkg-config case.

https://bugzilla.gnome.org/show_bug.cgi?id=783270
2017-08-17 17:17:59 +08:00
Simon McVittie
7c97e3d784 gdbus: Check signature of NameAcquired, NameLost
Calling g_variant_get (parameters, "(&s)") when parameters has a
signature other than (s) is considered to be a programming error.
In practice the message bus (dbus-daemon or a reimplementation) should
always send the expected type, but be defensive.

(Modified by Philip Withnall to improve type check.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:31:31 +01:00
Simon McVittie
c53b44edb2 GBusNameOwnerFlags: Add DO_NOT_QUEUE flag
PulseAudio and LibreOffice are among the services that use this flag.
Refusing to queue for a name lets you do this transaction,
but atomically, avoiding the transient state where you briefly join
the queue and then are given the name when its primary owner drops it:

    result = RequestName(name)

    if result == IN_QUEUE:
        ReleaseName(name)
        result = EXISTS

    return result

(Modified by Philip Withnall to add documentation.)

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

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:16:07 +01:00
Simon McVittie
92f1ba200d GBusNameOwnerFlags: Note equivalence with D-Bus Specification
The implementation passes flags through directly to the RequestName()
call, so if any new values break that equivalence, the implementation
will have to be changed.

Signed-off-by: Simon McVittie <smcv@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=784392
2017-08-07 17:10:07 +01:00
Philip Withnall
05abc6cfce gio: Fix crash in open URI portal when no callback is provided
If no callback is provided, token is never set, but it’s then passed to
g_variant_new_string(), which requires a non-NULL input.

Fix that by moving all the option handling inside the (callback != NULL)
case.

Spotted by Coverity (CID #1378714).

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

https://bugzilla.gnome.org/show_bug.cgi?id=785817
2017-08-07 17:08:07 +01:00
Philip Withnall
1782219fb8 docs: Fix typo in GDBusInterfaceSkeleton documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-08-04 13:30:10 +01:00
Philip Withnall
ad9d5a11f2 tests: Fix gschema-compile test for translatable string changes
Little did I know when making commit
c257757cf6 that a lot of the output of
glib-compile-schemas is string matched in some of the unit tests. Fix
them to match the updated strings.

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 16:32:42 +01:00
Philip Withnall
25c01e1c55 glib-compile-schemas: Use double quotes rather than single quotes
It’s what GLib is standardising on. See bug #772221.

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 16:31:37 +01:00
Daniel Macks
f7a14fece4 Use "-module" when compiling loadable modules
Some platforms use different extensions for compile-time linkable
libraries vs runtime-loadable modules. Need to use special libtool
flag in the latter case for consistency with what gmodule expects.

https://bugzilla.gnome.org/show_bug.cgi?id=731703
2017-08-03 12:28:10 +01:00
Philip Withnall
c257757cf6 glib-compile-schemas: Improve some translatable strings
• Fix capitalisation to be consistent
 • Use Unicode quotation marks where appropriate
 • Move trailing \n characters out of the translable strings and append
   them unconditionally

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

https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:41:13 +01:00
Daniel Boles
94816e10d2 glib-compile-schemas: Fix typo in newly translatable string 2017-08-03 11:30:20 +01:00
Jiro Matsuzawa
a7aa8acc48 glib-compile-schemas: Mark missing strings for translation
https://bugzilla.gnome.org/show_bug.cgi?id=695573
2017-08-03 11:19:08 +01:00
Philip Withnall
f2b6c11629 gstrfuncs: Expand documentation for errno functions
Mention that it really is a good idea to save errno before doing
literally anything else after calling a function which could set it.

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

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Philip Withnall
5cddde1fb2 Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.

errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
  int errsv, ret;
  ret = some_call_which_might_set_errno ();
  errsv = errno;

  if (ret < 0)
    puts (strerror (errsv));

This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
  if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Ondrej Holy
41a4a70b43 gunixmounts: Add missing const qualifier for mtab path
get_mtab_read_file and get_mtab_monitor_file returns const path,
but const qualifier is missing. Let's add it.

https://bugzilla.gnome.org/show_bug.cgi?id=779607
2017-08-03 10:22:43 +02:00
Ondrej Holy
2db36d0d5c gunixmounts: Prevent "mounts-changed" race if /etc/mtab is used
The /etc/mtab file is still used by some distributions (e.g. Slackware),
so it has to be monitored instead of /proc/self/mountinfo in order to
avoid races between g_unix_mounts_get and "mounts-changed" signal. The
util-linux is built with --enable-libmount-support-mtab in that case and
mnt_has_regular_mtab is used for checks. Let's use mnt_has_regular_mtab
also to determine which file to monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=779607
2017-08-03 10:22:43 +02:00
Debarshi Ray
b51a0e7c63 GApplication: Use a WARNING if dbus_unregister is called by destructor
Unlike g_application_register, there is no public API to unregister the
GApplication from D-Bus. Therefore, if the GApplication is set up
manually without using g_application_run, then neither can the
GApplicationImpl be destroyed nor can dbus_unregister be called before
destruction.

This is fine as long as no sub-class has implemented dbus_unregister.
If they have, their method method will be called after destruction, and
they should be prepared to deal with the consequences.

As long as there is no public API for unregistering, let's demote the
assertion to a WARNING. Bravehearts who don't use g_application_run
can continue to implement dbus_unregister, but they would have been
adequately notified.

This reverts commit c1ae1170fa.

https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-24 19:52:48 +02:00
Debarshi Ray
df06dc6550 GApplication: Don't call dbus_unregister multiple times
https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-24 19:52:48 +02:00
Debarshi Ray
c1ae1170fa GApplication: Assert that dbus_unregister was called before destruction
Invoking the dbus_unregister virtual method during destruction is
problematic. It would happen after a sub-class has dropped its
references to its instance objects, and it is surprising to be asked to
unexport exported D-Bus objects after that.

This problem was masked as a side-effect of commit 21b1c390a3.
Let's ensure that it doesn't regress by asserting that dbus_unregister
has happened before destruction.

Based on a patch by Giovanni Campagna.

https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-20 15:31:41 +02:00
Adrian Perez de Castro
f8a88a768d Map G_NOTIFICATION_PRIORITY_HIGH to NOTIFY_URGENCY_NORMAL
When using the Freedesktop backend for GNotification, it seems like a
better idea to map G_NOTIFICATION_PRIORITY_HIGH to NOTIFY_URGENCY_NORMAL
(instead of NOTIFY_URGENCY_CRITICAL) provided that the difference
between GNotification's NORMAL and HIGH priorities is minor.

Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>

https://bugzilla.gnome.org/show_bug.cgi?id=784815
2017-07-18 17:31:29 -04:00
Matthias Clasen
9424facde2 2.53.4 2017-07-17 16:20:52 -04:00
Emmanuele Bassi
683809d5f7 Use env for gdbus-codegen's script
This allows us to build with Python 3 without using an absolute path.
2017-07-14 22:05:01 +01:00
Thibault Saunier
be8820128f meson: fix remaining wrong #include's for gdbus_codegen files
This is a follow up on 266bc1e510
to fix building tests and examples when using GLib as a meson
subproject.
2017-07-13 22:22:16 -04:00
Matthias Clasen
653be67d7d Add gopenuriportal.c to the meson build
This was added recently.
2017-07-13 19:34:21 -04:00
Alessandro Decina
4db695bfb7 meson: replace meson.current_source_dir() with files()
As the meson reference doc says, files() is preferred over building
paths with current_source_dir().
2017-07-13 19:03:39 -04:00
Alessandro Decina
266bc1e510 meson: fix wrong #include's for gdbus_codegen files
When building glib as a subproject, #include's for xdp-dbus.h from xdp-dbus.c
and for gdbus-daemon-generated.h from gdbus-daemon-generated.c were generated as
being prefixed with the subproject prefix, eg
 #include "subproject/glib/gio/gdbus-daemon-generated.h".
That failed since the root of the build directory is obviously not part of the
include path when building a subproject.

Passing --output-directory @OUTDIR@ to gdbus-codegen and removing @OUTDIR@ from
--generate-c-code fixes the issue.
2017-07-13 19:03:39 -04:00
Thibault Saunier
eb2196e89d meson: Fix building as a subproject
meson.source_root() returns the toplevel source directory
of the toplevel project, thus the paths were wrong when using
it. Simply using files() gets us the right path

https://bugzilla.gnome.org/show_bug.cgi?id=784133
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
10ae386727 meson: gio tests need to link against gobject as well
With meson from git dependencies of dependencies are no
longer added automatically and recursively to the linker
lines. Meaning dependencies that are used have to be
passed directly and explicitly or we'll get linker errors.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
42705b57f7 meson add missing gio/tests subdirectory/file 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
03eac5fac5 meson: rebase on top of master ~2.53.1
From 2.51.2
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
6af4f1752a meson: gio/tests: remove some leftover rubbish 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
613e00826e meson: gio/tests: add more gio tests
Need to fix up some of the tests a little, because the
test binary will not necessarily be run from the current
build sub-directory, and the build directory structure
might not always be a mirror of the source directory
structure, so pass location of glib-mkenums and
glib-compile-scheme and such directly.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
1acd6de763 meson: Use glib-mkenums directly instead of via build_mkenum.py
This is no longer needed because we use templates and custom targets
can capture output just fine on all platforms.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
dd8ff54736 meson: Use Python port of glib-mkenums
This reduces the build-time dependencies of glib to only Python 3,
Meson, and git. Git is also optional if you provide a tarball in
which the subproject directories already exist.

The Python port was done by Jussi Pakkanen on bugzilla:
https://bugzilla.gnome.org/show_bug.cgi?id=779332

This version contains some fixes from that and also changes all
instances of `@` to `\u0040` because Meson does not yet provide a
configure_file() mode that ignores unknown @MACRO@ values.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
ee94ad776e meson: Use proxy-libintl if gettext is not found
This is a stub-only library that can be used while building against
MSVC and contains no i18n machinery at all.

The dependencies added indirectly use the libintl.h header, and when
built as a subproject, the header won't be in a path known the
pre-processor.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
192cd652d4 tests: gio/tests: add gdbus tests 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
4e0ef7655d meson: gio/tests: add more gresource tests 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
2f29ee1735 meson: add -fvisibility=hidden explicitly to selected targets
Don't use it project-wide for building everything. Otherwise
symbols for shared modules won't be exposed, e.g. in the
resourceplugin used by the gio resource unit test.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
34e4e25d53 meson: gio/tests: add more missing tests 2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
f438c04fac gio: tests: rename generated giotypefunc.c to giotypefuncs.inc
This is needed for the Meson port, a file name .c that's included
and shouldn't be compiled into an object is difficult to manage
otherwise.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
33fb1bbb61 meson: gio, gobject: use files() for headers list
Since these variables are referenced from other directories
such as the tests/ subdir as well.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
d29f022b0b meson: add support for dtrace/systemtap
Still at least one FIXME. And untested so far. It builds.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
9fdcb2bf37 meson: Add a comment about the gdbus-peer gio test
So that it's not forgotten later.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
3c62619930 tests: autoptr test can be run on gcc, clang, intel
The only place where it won't work, is MSVC and maybe Sun Studio, but
we'd need someone to test Sun Studio first.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
122f4c051d meson: Add tls-interaction test, and fix giomodule test
giomodule test needed symbol visibility pragmas added. This is needed on
Windows anyway, so it's better to do it this way rather than disabling
-fvisibility=hidden for the test modules.
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
e2da3cb599 meson: Port to latest master (2.51.0)
Also remove headers from some gio sources. Headers do not need to be
added to the list of sources.

+ various smaller self-explanatory fixes.
2017-07-13 19:03:39 -04:00
Patrick Griffis
d10be6102f meson: Minor modernizations 2017-07-13 19:03:39 -04:00
Patrick Griffis
a690e2a375 meson: More build fixes
- Fix installing various data files
- Build translations
2017-07-13 19:03:39 -04:00
Nirbheek Chauhan
fe2a9887a8 meson: Improve MSVC and MinGW support and fix dependencies everywhere
Disable gio tests on Windows, fix .gitignore to not ignore
config.h.meson, and add more things to it.

Rename the library file naming and versioning to match what Autotools
outputs, e.g., libglib-2.0.so.0.5000.2 on Linux, libglib-2.0-0.dll  and
glib-2.0-0.dll on Windows with MSVC.

Several more tiny fixes, more executables built and installed, install
pkg-config and m4 files, fix building of gobject tests.

Changes to gdbus-codegen to support out-of-tree builds without
environment variables set (which you can't in Meson). We now add the
build directory to the Python module search path.
2017-07-13 19:03:39 -04:00
Tim-Philipp Müller
213957970e meson: Fix glib, add gobject, gio, gthread, gmodule, etc
Several small fixes to the build files.

Lots of tests have also been added, and glib tests pass now.
2017-07-13 19:03:39 -04:00
Daniel Boles
5eededccda gsettingsschema: Fix a compiler warning
g_build_filename() returns a gchar*, but it was stored in a const gchar*
and then g_free()d, which is wrong and led to a warning about the const
qualifier being cast away.
2017-07-12 19:23:40 +01:00
Philip Withnall
a131134918 build: Drop nmake/MSC build system for GLib
It hasn’t been seriously maintained for the best part of 10 years and is
very outdated. The recommended way to build GLib on Windows is now
Visual Studio:

https://wiki.gnome.org/Projects/GTK%2B/Win32/MSVCCompilationOfGTKStack#GLib

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

https://bugzilla.gnome.org/show_bug.cgi?id=722047
2017-07-10 11:22:40 +01:00
Matthias Clasen
28cc6aeb19 gsettings: Try harder to describe keys
If a key has no description, show the summary,
rather than "(null)". Since thats not helpful at all.
2017-07-07 19:11:51 -04:00
Matthias Clasen
85e4a25912 Avoid a race with the openuri portal
Same as the previous commit; use the new predictable request
object path to connect to the Response signal early.
2017-07-07 11:54:54 -04:00
Bastien Nocera
a95e2a4c64 docs: Fix cut'n'paste error in g_resources_get_info() doc
https://bugzilla.gnome.org/show_bug.cgi?id=784581
2017-07-05 23:50:04 +02:00
Philip Withnall
5a8b02cae6 gdbusutils: Add an example to g_dbus_gvariant_to_gvalue() docs
Clarify that GVariants of type v are not magically unboxed.

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

https://bugzilla.gnome.org/show_bug.cgi?id=784433
2017-07-04 10:45:50 +01:00
Matthias Clasen
f39024038f Disambiguate source names
This makes debugging more pleasant.
2017-06-28 19:50:57 -04:00
Emanuele Aina
79e4d4c6be gio: Mention the ALL_METADATA flag in g_file_copy()
The g_file_copy() documentation didn't mention if
G_FILE_COPY_ALL_METADATA was applicable or not, and users were led to
call g_file_copy_attributes() to specify it after the g_file_copy()
call, unless they checked the source (been there, done that).

https://bugzilla.gnome.org/show_bug.cgi?id=784037
2017-06-21 15:54:11 +02:00
Philip Withnall
18f8b77c04 gio: Use g_strerror() instead of strerror()
This marginally improves thread safety, and marginally improves
consistency.

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

https://bugzilla.gnome.org/show_bug.cgi?id=733821
2017-06-21 11:20:29 +01:00
Colin Walters
017f78d77f gtype: Add private DEFINE_TYPE with prelude to workaround gtype deadlocks
And use it in GSocket, as it had a real-world case reported.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-06-14 14:45:45 -04:00
Ting-Wei Lan
45d4b59e3f glocalfileoutputstream: Fix symlink writing on FreeBSD and NetBSD
FreeBSD, DragonflyBSD and NetBSD support O_NOFOLLOW, but they use error
numbers that are different from what POSIX standard specifies. They are
not going to change the behavior, and existing programs on these systems
already take advantage of this difference. To support them, we have to
add a check in GIO to use different error numbers on these systems.

https://bugzilla.gnome.org/show_bug.cgi?id=775593
2017-06-10 20:55:12 +08:00
Simon McVittie
34045e66a6 GGtkNotificationBackend: Use correct path for GetNameOwner call
For historical reasons, the reference dbus-daemon responds to most
method calls on all object paths. However, the canonical path
of the object implementing the o.fd.DBus interface is
/org/freedesktop/DBus, and in some environments (notably AppArmor
with the <abstractions/dbus-session-strict> abstraction) only this
path is allowed.

https://bugs.freedesktop.org/show_bug.cgi?id=101256 officially
deprecates all other object paths, and when adding new APIs we will
only make them available on the canonical object path.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Emmanuele Bassi <ebassi@gnome.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=783593
2017-06-09 16:45:09 +01:00
Ondrej Holy
6863080c32 gio-tool: Fix alignment of monitor messages
Name of GMount/GVolume/GDrive is aligned in many cases in output messages,
except few cases. Let's unify the alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-06-06 11:11:58 +02:00
Philip Withnall
085b3470f0 gdbusintrospection: Remove incorrect (out) annotations
The caller passes in a GString instance which is then modified by the
function, rather than the function building its own GString and passing
it out to the caller.

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

https://bugzilla.gnome.org/show_bug.cgi?id=783392
2017-06-05 16:07:52 +01:00
Philip Withnall
f98d998267 gdatainputstream: Annotate (out) length arguments as (optional)
All of them are.

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

https://bugzilla.gnome.org/show_bug.cgi?id=783350
2017-06-05 16:04:18 +01:00
Sébastien Wilmet
eea0681574 LGPLv2+ -> LGPLv2.1+: update remaining files
For the files in gio/ (but not in gio/ sub-directories), only the *.[ch]
files were handled in commit 3bf4a720c3.

For the modified files in glib/tests/markups/, I've tested that
`make check` still succeeds.

After this commit,
$ git grep -in "GNU Library"
and
$ git grep -in "Library General"
return only results in COPYING files and in glib/libcharset/. The latter
was not updated because it's a copy.

$ git grep -in "version 2" | grep -iv "version 2\.1"
now doesn't return any LGPL license header.
- glib-gettextize.in: GPL
- glib/gen-unicode-tables.pl: GPL
- glib/gnulib/: a copy
- glib/libcharset/: a copy
- m4macros/attributes.m4: GPL
- po/po2tbl.sed.in: GPL
- tap-driver.sh: GPL
- tests/*.pl: GPL

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-06-03 10:30:17 +02:00
Matthias Clasen
34b21312f1 appinfo: Fix the build on windows
The previous commit forgot to protect some unix-only
calls by an ifdef.

Pointed out by John Emmas.
2017-06-02 22:04:46 -04:00
Patrick Griffis
7c5cd293d0 Fix g_file_copy_async() annotation
https://bugzilla.gnome.org/show_bug.cgi?id=776333
2017-06-02 13:44:16 -04:00
John Lindgren
d1d60fc846 NtNotifyChangeMultipleKeys is a __stdcall function.
https://bugzilla.gnome.org/show_bug.cgi?id=781301
2017-06-01 11:00:28 +00:00
Philip Withnall
4dd1b17c24 gdbus: Fix race in name watching on connection teardown
If g_dbus_unwatch_name() is called from one thread at the same time as
the GDBusConnection is emitting ::disconnected in another thread, there
will be a race and the handler for ::disconnected may end up using
memory after it’s freed.

Fix this by serialising through the map_id_to_client, so that
on_connection_disconnected() atomically gets a strong reference to the
Client, or NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=777307
2017-06-01 11:39:40 +01:00
Matthias Clasen
97068f363e OpenFile support: Handle open failing
This can happen, report it as an error when it does.
2017-05-31 12:10:58 -04:00
Philip Withnall
e1e73dafa6 gsubprocess: Copy parent process’ environ when clearing subprocess’
Previously, this was done at the time of spawning the subprocess, which
meant the g_subprocess_launcher_*_environ() functions could not be used
to modify the parent process’ environment.

Change the code to copy the parent process’ environment when
g_subprocess_launcher_set_environ(NULL) is called. Document the change
and add a unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=778422
2017-05-31 12:07:31 +01:00
Philip Withnall
c7d325733c docs: Mention GtkApplication in the GResource documentation
Since GtkApplication auto-loads some well-known resource paths. Add a
cross-reference to its documentation. (The cross-reference won’t be
linked if the GTK+ documentation isn’t available at build time, but this
is probably good enough. It is likely to be available.)

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

https://bugzilla.gnome.org/show_bug.cgi?id=782336
2017-05-31 11:09:51 +01:00
Philip Withnall
678899e87a docs: Mention the alias GResource attribute in the documentation
It was the only part of the XML format which was not documented.

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

https://bugzilla.gnome.org/show_bug.cgi?id=782336
2017-05-31 11:08:05 +01:00
Philip Withnall
29b4e9b05f docs: Improve formatting and fix typos in GResource documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-31 10:55:45 +01:00
Matthias Clasen
4c8ab22b95 Use OpenFile for local files
The OpenURI portal has a separate method to handle local
files now. Use it.

At the same time, split out the openuri helpers into separate
files, and generate code for the OpenURI portal.

https://bugzilla.gnome.org/show_bug.cgi?id=783193
2017-05-30 14:23:10 -04:00
Florian Müllner
99d34f65d3 gdbus-codegen: Apply --output-directory to generated docs as well
In addition to code, gdbus-codegen can also generate docbook
documentation for DBus interfaces. There's no good reason why
the newly added --output-directory option shouldn't apply to
those generated files as well.

https://bugzilla.gnome.org/show_bug.cgi?id=783201
2017-05-30 00:08:38 +02:00
Matthias Clasen
d3b4f7c9f6 Make dbus activation sandbox-aware
When we call org.freedesktop.Application.Open to activate
an application and pass file uris, the application may not
be able to see the files due to a flatpak sandbox.

Flatpak puts the flatpak app-id in the  X-Flatpak key in
desktop files that it exports, so we can easily recognize
applications that may be affected by this.

In this case, call the document portal to export the files
and pass the resulting uri's instead of the original ones.

https://bugzilla.gnome.org/show_bug.cgi?id=783130
2017-05-29 17:57:39 -04:00
Matthias Clasen
60a1cc9fac Add a wrapper for the AddFull document portal api
This is a wrapper which takes a list of uris and rewrites
them by calling AddFull with the file:// uris.

https://bugzilla.gnome.org/show_bug.cgi?id=783130
2017-05-29 17:57:39 -04:00
Matthias Clasen
a76fc7fa76 Update flatpak document portal interface
This api has been changed upstream, recently.

A new AddFull method has been added in this commit:
6ce8521b64

https://bugzilla.gnome.org/show_bug.cgi?id=783130
2017-05-29 17:57:39 -04:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
90afd3b775 gio/xdgmime/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
408381b8ae gio/win32/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
d9a44b66af gio/tests/: LGPLv2+ -> LGPLv2.1+
A lot of tests in gio/tests/ don't have a license header.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
6000f25e4f gio/inotify/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
ae4bac0ada gio/gvdb/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
0fedc90fac gio/gdbus-2.0/codegen/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Sébastien Wilmet
57cd1b4239 gio/fam/: LGPLv2+ -> LGPLv2.1+
There is only one *.c file in gio/fam/.

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Philip Withnall
fae61260c6 gtlspassword: Fix a typo in a translatable string
Singular/Plural mismatch.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-29 11:24:09 +01:00
Juan R. Garcia Blanco
d865ffa4d5 gtlspassword: Comment for translators added
With tweaks by Philip Withnall <philip@tecnocode.co.uk>.

https://bugzilla.gnome.org/show_bug.cgi?id=658446
2017-05-29 11:22:28 +01:00
Chun-wei Fan
7f41633efd gio/gdbusprivate.c: Include missed headers
This ensures the needed GTYPE_*'s can be found during the build
2017-05-27 00:23:54 +08:00
Matthias Clasen
b5e8e4eea9 GApplication: Remove some unused members
All the menu handling is in GtkApplication, these fields
are entirely unused, and can go away.

https://bugzilla.gnome.org/show_bug.cgi?id=783061
2017-05-25 14:50:34 -04:00
Colin Walters
a0ed9bc8d6 gdbus: Init more types to work around gtype thread issue
See https://bugzilla.gnome.org/show_bug.cgi?id=674885#c85

In this pass I also went through and added more types from GDBusConnection.
2017-05-22 09:20:45 -04:00
Ryan Hendrickson
151d3b01e6 gsettings: check $XDG_DATA_HOME for schemas
Add $XDG_DATA_HOME/glib-2.0/schemas as a schema source, after (higher
priority than) $XDG_DATA_DIRS/glib-2.0/schemas but before
$GSETTINGS_SCHEMA_DIR. This is per the XDG Base Directory Specification,
which states that user specific versions of data in $XDG_DATA_DIRS can
be created in $XDG_DATA_HOME.

https://bugzilla.gnome.org/show_bug.cgi?id=741335
2017-05-22 09:18:25 +01:00
Philip Withnall
3de1fac392 docs: Fix a trivial typo in GMount documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-17 13:40:06 +01:00
Philip Withnall
7f8ae236a7 docs: Fix a trivial typo in GMount documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-17 13:37:02 +01:00
Mohammed Sadiq
274f336f6a docs: Trivial typo fixes
The presence of space was resulting in wrongly rendered documentation
in devhelp (and probably in other documentations).

https://bugzilla.gnome.org/show_bug.cgi?id=782068
2017-05-16 11:22:54 +01:00
Alexandru Pandelea
eb7b796bd2 xdgmime: fix special case for mime_type_subclass
Currently, all mime types are considered subclasses of
application/octet-stream, but according to the freedesktop
standard, everything but the inode/* types is a subclass of
application/octet-stream.

Update the special case for application/octet-stream so that all
types but inode/* will match with it and add unit test for it.

https://bugzilla.gnome.org/show_bug.cgi?id=782311
2017-05-16 11:16:41 +01:00
Lars Uebernickel
0751ccd315 gdbus: fix use-after-free
g_dbus_connection_call_internal() accesses the user data it passes to
g_dbus_connection_send_message_with_reply() after the call. That data
might be freed already in the case that the callback is called
immediately.

Fix this by removing the 'serial' field from the user data altogether
and fetch the serial from the message in the callback.

https://bugzilla.gnome.org/show_bug.cgi?id=748263
2017-05-12 14:43:22 -04:00
Krzesimir Nowak
b89fed057c docs: Fix typos
Something I spotted by accident with git log.
2017-05-10 12:44:59 +02:00
Ondrej Holy
83c1b881fb gunixmounts: Prevent unwanted automount requests
mnt_table_is_fs_mounted causes unwanted automount requests due to
canonicalization of source and target. It might be replaced by
mnt_table_find_source as per the documentation in order to prevent
the automounts, but it is redundant. All mtab entries should be already
mounted and thus mnt_table_is_fs_mounted result is always true (it
basically checks that the fs from mtab is in mtab). Let's remove
the check at all.

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-05-09 14:28:48 +02:00
Ondrej Holy
53ed1804e2 gunixmounts: Speed up mtab processing with libmount
libmnt_context is useless. It contains cache which is useful for searching,
but it isn't used in our case. Let's use mnt_context_parse_mtab instead
directly and the mtab processing will be faster.

https://bugzilla.gnome.org/show_bug.cgi?id=781867
2017-05-09 14:28:48 +02:00
Rico Tzschichholz
17395d79eb Revert "ginputstream: Add missing (out) annotations to read() functions"
This reverts commit 8446ee8c20.
2017-05-04 16:27:39 +02:00
Matthias Clasen
6ddfd516e6 Small documentation additions
The GNetworkMonitor docs were talking about one implementation,
omitting the others. While fixing that, add a bit about implementations
to the GProxyResolver docs too.
2017-05-02 07:23:32 -04:00
Matthias Clasen
f340354861 portal support: Raise the priority for network monitor
When we are inside a sandbox, we want to use the portal
implementation, since it is the only one that has a chance
of working.

This is safe to do, since the portal implementation will
just fail initialization when loaded outside a sandbox.
2017-05-02 06:48:35 -04:00
Philip Withnall
f5993c0e5d gportalsupport: Fix compilation failure from previous commit
Igor says: Thith code did not path the compilation check.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-05-01 19:34:51 +01:00
Matthias Clasen
82e31de04d portal support: Read /.flatpak-info
The flatpak-info file was moved to a different location a while
ago, we should read it from there instead of relying on the
compat symlink. One advantage is that this is a fixed, short
path, we don't have to construct one dynamically.

https://bugzilla.gnome.org/show_bug.cgi?id=781826
2017-05-01 14:15:44 -04:00
Philip Withnall
84134c64ed docs: Remove some extraneous words from g_settings_sync() documentation
Looks like the author started typing one thing, then changed their mind
about how to phrase the sentence, and typed something else.

Signed-off-by: Philip Withnall <philip@tecnocode.co.uk>
2017-04-30 22:04:17 +01:00
Timm Bäder
3e2187975d gappinfo: Clear previously set error before calling portal
Otherwise, we might end up returning TRUE from
g_app_info_launch_default_for_uri but with a set error parameter. This
will lead to confusing results depending on how the caller checks for
errors. Checking error != NULL indicats the call failed but checking the
return value indicates that it succeeded.
2017-04-29 15:15:49 +02:00
Patrick Griffis
cbcf10411c tests: Fix g_content_type_is_mime_type() test on OSX
It should be passed a mime type not a content type.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-29 03:47:54 -04:00
declan
aefffa3fbc gdbusmessage: Don’t use major()/minor() if they’re unavailable
https://bugzilla.gnome.org/show_bug.cgi?id=777030
2017-04-28 15:26:28 +01:00
Philip Withnall
b63469d726 docs: Fix (nullable) (optional) annotations
There are a few places where commit 18a33f72 replaced valid (nullable)
(optional) annotations with just (optional). That has a different
meaning.

(nullable) (optional) can only be applied to gpointer* parameters, and
means that both the gpointer* and returned gpointer can be NULL. i.e.
The caller can pass in NULL to ignore the return value; and the returned
value can be NULL.

(optional) can be applied to anything* parameters, and means that the
anything* can be NULL. i.e. The caller can pass in NULL to ignore the
return value. The return value cannot be NULL.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-28 12:32:12 +01:00
Philip Withnall
88ad0dab21 gdbusconnection: Add some comments about object ownership
Some annotations I made while trying to debug bug #781847. They
introduce no behavioural changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-28 12:06:25 +01:00
Daniel Macks
ea586b47a3 Implement g_content_type_is_mime_type() (clone of win32's)
Add missing function, copying from gcontenttype-win32.c per Patrick
Griffis (Comment #55 of bug report)

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Daniel Macks
ecc27a0cba Add test-case for g_content_type_is_mime_type()
Verify presence of new interface.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Rafal Luzynski
643c722f1e gosxappinfo: fix typo in g_osx_app_info_launch_internal
Correct error domain is G_IO_ERROR.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
0c4dd4a802 gosxappinfo: Special case x-scheme-handler
This is the only way they are exposed on Unix so we need to handle it

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
fac83e09d6 gosxappinfo: Fix get_default_for_type() on 10.10+
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-04-28 06:30:11 -04:00
Patrick Griffis
d4bfee1e7a build: Don't build dbus-appinfo on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=780309
2017-04-27 21:52:04 -04:00
Patrick Griffis
f3321da462 gosxappinfo: Fix typo in ifdef
https://bugzilla.gnome.org/show_bug.cgi?id=780300
2017-04-27 09:35:29 -04:00
Philip Withnall
c192595268 ginputstream: Add missing (transfer full) annotation to read_bytes() 2017-04-13 10:25:25 +01:00
Philip Withnall
8446ee8c20 ginputstream: Add missing (out) annotations to read() functions
https://bugzilla.gnome.org/show_bug.cgi?id=781234
2017-04-13 10:24:11 +01:00
Philip Withnall
8c4a6fdbf5 gio: Fix some typos of ‘asynchronous’ in documentation comments 2017-04-13 10:23:50 +01:00
Víctor Manuel Jáquez Leal
3d7534eae5 gio-tool: Fix errors format string
Compiling with clang 3.8.1-18 (debian, x86_64) I ran across this
error:

gio-tool.c:40:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  message = g_strdup_vprintf (format, args);
                              ^~~~~~
gio-tool.c:55:31: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  message = g_strdup_vprintf (format, args);
                              ^~~~~~
2 errors generated.

To fix the first one, related with the function print_error(), this
patch adds to the function prototype a compiler's attribute.

For the second one, since the usage of that function is to print
one string and the format is already provided, the patch simplifies
the function by no receiving variadic arguments.

https://bugzilla.gnome.org/show_bug.cgi?id=781125
2017-04-10 15:43:12 +02:00
Piotr Drąg
77d00030e5 gio-tool: Fix closing Unicode quotation mark
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2017-04-10 15:40:42 +02:00
Emmanuele Bassi
f952fdf3fc Drop trailing semi-colon from G_DEFINE_ macro
It's unnecessary, and only adds visual noise; we have been fairly
inconsistent in the past, but the semi-colon-less version clearly
dominates in the code base.

https://bugzilla.gnome.org/show_bug.cgi?id=669355
2017-04-10 10:38:31 +01:00
Ondrej Holy
fb7d2184a6 gio-tool: Do not leak GOptionContext
GOptionContext is freed only in case of success. Free the context
also in case of failure.

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ondrej Holy
292f10d053 gio-tool: Add g_drive_is_removable() support
The g_drive_is_removable() support was added recently in gio/gvfs
(see Bug 765900 and Bug 765457). It was also added in gvfs-mount,
but we forgot to add it also in gio-tool-mount.

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ondrej Holy
094613425e gio-tool: Return error if there are not any volumes to mount
Print error and return error code if device doesn't contain any
volumes to mount.

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ondrej Holy
bcb1bfda52 gio-tool: Do not print settable arguments unless they are any
"Settable arguments:" is printed even if they are not any arguments
to print. Do not print it similarly as it is done for "Writable
namespaces:".

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ondrej Holy
bde2bde411 gio-tool: Various memory leak fixes
https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ondrej Holy
0beeeb2ec9 gio-tool: Various fixes related to error messages
This patch contains the following changes:
- Print all errors with "gio: " prefix
- Print file uri in error for each tool allowing multiple locations
- Mark all error messages translatable
- Do not leak strings used in error messages
- Always start error messages with capital letter
- Unify some error messages across various tools
- Fix addional/missing new line characters

https://bugzilla.gnome.org/show_bug.cgi?id=776169
2017-04-10 10:14:04 +02:00
Ole André Vadla Ravnås
005dfeacba gdbus: fix false positive g_warning() in remove_filter()
The GDBus thread might be holding a ref while requesting to remove the
filter.

https://bugzilla.gnome.org/show_bug.cgi?id=779409
2017-04-08 01:13:06 -04:00
Adrian Perez de Castro
85882094df Better documentation for g_app_info_equal()
Explicitly state that the function may not compare the contents of the
passed GAppInfo instances.

This fixes bug #777961.
2017-04-08 01:12:16 -04:00
Alexandros Frantzis
feae4e9f31 gdbus: Fix memory leak in gdbusmethodinvocation.c
https://bugzilla.gnome.org/show_bug.cgi?id=780924
2017-04-05 13:12:14 +01:00
Debarshi Ray
4efb8b4f7b docs: Clarify the use of the GError in g_tls_database_verify_chain*
Being able to determine that a certificate chain is invalid is not
considered an error, but success. This might not be obvious at first
due to the way the method is named and described currently. Since we
cannot change the name, let's improve the description and clarify this
aspect of its behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=780310
2017-04-03 18:57:48 +02:00
Philip Withnall
ca0632ca5c gio: Handle NULL cached properties in NetworkManager monitor
g_dbus_proxy_get_cached_property() and
g_dbus_proxy_get_cached_property_names() can both return NULL if the
property cache is empty. Avoid a crash if this situation arises (which
it looks like it could, from reading the code) by gracefully bailing out
on NULL return values.

Coverity issues: #1257044, #1257045

https://bugzilla.gnome.org/show_bug.cgi?id=741229
2017-04-03 12:04:23 +01:00
Philip Withnall
1f396fd7d6 gsocket: Fix potential multiplication overflow calculating timeout
socket->priv->timeout is only a guint, and the multiplication is
performed before it’s widened to gint64 to be stored in start_time
(thanks, C). This means any timeout of 50 days or more would overflow.
Fixing this bug makes me feel a real sense of self-worth.

Coverity ID: 1159478

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-03 11:56:43 +01:00
Philip Withnall
0e0b5dff7c gdbus-tool: Improve --help output for gdbus wait
Include a parameter placeholder for the bus name, which is required.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-03 11:53:28 +01:00
Philip Withnall
fe2813b842 gdbus-tool: Drop a few lines of dead code
request_completion is checked several blocks higher in the function.
Spotted by Coverity.

Coverity ID: 1373215

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-04-03 11:43:18 +01:00
Philip Withnall
2f2c2b6362 gobject: Fix Since/Deprecated versions for GParameter replacement API
This slipped through the review cracks.

https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:09:53 +01:00
Philip Withnall
c11908ab7d gio: Fix deprecation warnings for g_object_newv() API 2017-03-31 11:00:23 +01:00
Fabian Orccon
3151da15d7 gio: Deprecate GParameter-related functions
https://bugzilla.gnome.org/show_bug.cgi?id=709865
2017-03-31 11:00:23 +01:00
Christoph Reiter
c20ab772b1 gosxappinfo: fix typo in url_escape_hostname
This duplicated everything after the hostname.

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-30 10:09:19 -04:00
Patrick Griffis
392bd59eb8 gosxappinfo: Fix launching default applications
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-30 10:09:19 -04:00
Philip Withnall
deab643651 ginitable: Relax idempotency requirements on init() and init_async()
The previously documented requirements for implementing init() and
init_async() as completely idempotent were really quite hard to achieve,
and brought a lot of pain for very little gain. Many implementations of
GInitable and GAsyncInitable did not actually follow the requirements,
or did not correctly handle concurrent init_async() calls.

Relax those requirements so that classes can decide whether their init()
or init_async() implementations need to be idempotent.

https://bugzilla.gnome.org/show_bug.cgi?id=766660
2017-03-30 10:24:09 +01:00
Christoph Reiter
625936343d Make GUnixMountEntry and GUnixMountPoint boxed types
And unskip some functions using them.

https://bugzilla.gnome.org/show_bug.cgi?id=668962
2017-03-28 18:03:08 +02:00
Philip Withnall
7890573f6e gdbus-tool: Add a command to wait for a well-known name on the bus
This is effectively the mc-wait-for-name tool from
telepathy-mission-control; moving it in to gdbus-tool will make it more
widely useful without making people depend on telepathy-mission-control
for no other reason. The code here is reimplemented from scratch to use
GDBus.

It blocks until the specified well-known name is owned by some process
on the bus (which can be the session, system, or any other bus). By
passing --activate, the same (or a different) name can be auto-started
on the bus first.

A timeout can be specified to ensure the process doesn’t block forever.

https://bugzilla.gnome.org/show_bug.cgi?id=745971
2017-03-28 11:23:27 +01:00
Colin Walters
ff7f32f643 gdbusprivate: Include a few headers to fix win32 build
Followup to previous commit.

See: https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-03-27 14:46:06 -04:00
Colin Walters
5b4b827e99 gdbus: Initialize types earlier to break proxy <-> connection deadlock
This will help us break generic GType deadlocks between people using
GDBus in different threads (which is supported), not just by GType
usage in the GDBus thread.

This should fix the common cases we're seeing in the wild, although I
have some lingering concerns that if someone e.g. referenced
e.g. `G_TYPE_DBUS_AUTH_MECHANISM_SHA1` etc. we'd need to add those
too.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-03-27 09:42:47 -04:00
INSUN PYO
07465176da gdbus: Initialize types at async entrypoints
This isn't a comprehensive fix, but should cover a lot of cases
for GDBus.

https://bugzilla.gnome.org/show_bug.cgi?id=674885
2017-03-27 09:42:47 -04:00
Patrick Griffis
206c54c80b gosxcontenttype: Fix various tests
https://bugzilla.gnome.org/show_bug.cgi?id=780384
2017-03-26 04:56:20 -04:00
Patrick Griffis
03c88daa73 build: Skip gdesktopappinfo tests on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=780384
2017-03-26 04:51:15 -04:00
Florian Müllner
05f0d8199b appinfo: Only use portal as fallback
We currently assume that the OpenURI portal should be used
unconditionally when running inside a flatpak sandbox. While
the portal is what we usually want, there are exceptions:
Yelp is now included in the GNOME runtime to allow displaying
help without exporting the user documentation, and the sandboxed
app itself may register a scheme handler.
To account for those cases transparently, always try the normal
code path first and only fall back to calling the portal when
that fails.

https://bugzilla.gnome.org/show_bug.cgi?id=780471
2017-03-25 22:43:58 +01:00
Marc-André Lureau
73c5e927d5 gio-querymodules: fix memory leak
Spotted thanks to ASAN.

https://bugzilla.gnome.org/show_bug.cgi?id=778207

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-03-24 12:50:30 +04:00
Philip Withnall
4091b2d19e gio: Drop redundant g_source_is_destroyed() calls
These calls cause race warnings from tsan, but are not a thread safety
problem, because we can only ever observe single bit changes: all
modifications to the GSource.flags field are done with a lock held; all
reads are of independent fields, so no intermediate state can ever be
observed. This assumes that a non-atomic read will consistently give us
an old value or a new value.

In any case, these g_source_is_destroyed() calls can happen from any
thread, and the state could be changed from another thread immediately
after the call returns; so the checks are pointless. In addition,
calling g_source_set_ready_time() or g_source_destroy() on a destroyed
source is not a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=778049
2017-03-23 15:00:19 +00:00
Mario Sanchez Prada
92cb02392c appinfo: Don't hardcode strings for the OpenURI portal's D-Bus method
We added several #define in the previous commit, so use those instead.
2017-03-23 14:46:02 +00:00
Mario Sanchez Prada
b374cc2e23 appinfo: Launch the OpenURI portal using a synchronous D-Bus call
Calling the D-Bus method for the OpenURI portal "protects" the logic from
not ever having the remote method running in case the xdg-desktop-portal
process is not yet running and the caller quits quickly after the call.

This should not be a problem as the method returns immediately (regardless
of the user making a selection), but making it synchronous would prevent
situations where the OpenURI method would never be called because of D-Bus
dropping the message after the caller dies, without explicitly waiting for
a reply.

https://bugzilla.gnome.org/show_bug.cgi?id=780441
2017-03-23 11:28:22 +00:00
Mario Sanchez Prada
26e0b3dde4 appinfo: Don't leak the session bus in launch_default_with_portal_async
The session bus object needs to be unreferenced before early returning.
2017-03-23 11:03:34 +00:00
Colin Walters
dd914da1c8 gio/fam: Remove leftover debug print
This leftover debug print was introduced by d682df186e
and is obviously bad for applications that are expecting something
else on stdout, etc.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1396386

https://bugzilla.gnome.org/show_bug.cgi?id=780144
2017-03-16 10:36:17 -04:00
Philip Withnall
2411b76c5e docs: Fix some DocBook usage in a few gtk-doc comments
<emphasis> and <ulink> tags. Replace them with Markdown.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-03-16 13:50:19 +00:00
Piotr Drąg
e9fe8868a7 Use single non-Unicode quotation marks in a new translatable message
Actually, Unicode changes to this file got reverted in
2d56c49b10. Also, there is
"No such interface '%s'" string already, so we avoid
breaking the string freeze.
2017-03-14 14:51:49 +01:00
Piotr Drąg
bb93f3a4aa Use consistent quotation marks in a new translatable message
Double quotation marks are used everywhere else in glib, as per
<https://developer.gnome.org/hig/stable/typography.html>.
2017-03-14 14:45:48 +01:00
Philip Withnall
e1f362ba49 gsubprocess: Add missing G_GNUC_NULL_TERMINATED attribute
g_subprocess_launcher_spawn() is NULL-terminated, and must have a
non-NULL argv0 specified, so G_GNUC_NULL_TERMINATED is appropriate here.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780032
2017-03-14 12:57:32 +00:00
Philip Withnall
ff327ba2d7 gdbusmessage: Add missing G_GNUC_PRINTF attribute
This highlighted a bug in GDBusConnection, where an interface name was
not included in a message referring to it.

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

https://bugzilla.gnome.org/show_bug.cgi?id=780032
2017-03-14 12:57:32 +00:00
Chun-wei Fan
e013164c5c Visual Studio builds: Fix gio project generation
We need to include gcontenttype-win32.c in our Visual Studio projects...
2017-03-14 14:48:23 +08:00
Matthias Clasen
37f5feb1d2 Fix distcheck
Typo in the win32 source list...
2017-03-13 12:30:56 -04:00
TingPing
90dfea2b61 Implement GAppInfo on OSX
This is an implementation of most of GAppInfo using the OS X
NSBundle APIs.

Missing at this point are things that don't have equivalents
in OS X, such as hidden desktop files, last-used, manual type
associations, and g_app_info_get_all().

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-13 10:33:23 -04:00
TingPing
3953d85a92 Implement GContentType on OSX
This is an implementation of most of GContentType using the OS X
UTType APIs.

Missing at this point is an implementation of
g_content_types_get_registered() and g_content_type_guess_for_tree().

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-13 10:32:02 -04:00
Steven McDonald
e305fe971e gio: Always purge kqueue subs from missing list
Previously, _kh_cancel_sub assumed that it only needed to call
_km_remove if sub did not exist in subs_hash_table. This is erroneous
because the complementary operation, _km_add_missing, can be called
from process_kqueue_notifications, in which context sub can *only* have
come from subs_hash_table.

Since _km_remove is implemented using g_slist_remove, which is
documented to be a noop if the list does not contain the element to be
removed, it is safe to call _km_remove unconditionally here.

https://bugzilla.gnome.org/show_bug.cgi?id=778515
2017-03-09 17:38:55 +00:00
TingPing
fe1a749ca6 Create g_content_type_is_mime_type()
Convenience wrapper around g_content_type_is_a().

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-08 23:02:10 -05:00
Matthias Clasen
a28429a3c6 Fix a typo 2017-03-08 22:36:05 -05:00
Matthias Clasen
04ad811e50 Add a forgotten g_type_ensure call
One of the types in this function was not wrapped in a
g_type_ensure_call, an obvious oversight.
2017-03-08 22:27:06 -05:00
John Ralls
d1a03bc728 Enable building gcocoanotification only if OS X min version >= 10.9
This changes the configure checks to check for what is actually
required to build this code.

https://bugzilla.gnome.org/show_bug.cgi?id=747146
2017-03-08 22:26:00 -05:00
Matthias Clasen
b56a95026c Add some more cases to the app-id unit tests
These came up on irc today.
2017-03-05 13:11:52 -05:00
Philip Withnall
d892cf6feb tests: Fix some memory leaks in the GSettings unit tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:06 +00:00
Philip Withnall
43fbb8652d tests: Fix a double-unref in the GSettings unit tests
g_settings_schema_source_get_default() is (transfer none), not (transfer
full).

Spotted by Marvin Schmidt.

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Philip Withnall
6bfb4ce191 gsettings: Fix a leak in GSettingsAction
Every GSettingsAction was leaking its schema key (a few tens of bytes).

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Philip Withnall
08b6794ec2 gsettings: Fix memory leak on error handling path for g_settings_set()
On the warning/critical error handling paths for g_settings_set(), the
GVariant value was not ref-sunk, and the schema key was leaked. This
won’t affect code in production (unless it’s seriously buggy), but
eliminates some leaks from the error testing paths in the GSettings
tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Philip Withnall
d6d29a2e9f glib-compile-schemas: Fix various memory leaks
Spotted while running `make check` under Valgrind. While it’s not
necessary to fix memory leaks in glib-compile-schemas (since it’s a
utility which runs briefly then exits), fixing them makes more
legitimate leaks in the Valgrind output more obvious, and means we can
be sure there aren’t leaks in the underlying GLib/GIO code which
glib-compile-schemas is calling.

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

https://bugzilla.gnome.org/show_bug.cgi?id=779265
2017-02-28 16:11:05 +00:00
Jan Tojnar
1a845115a2 gio: Check for NUll when getting extensions
When unregistered extension point (i.e. NULL pointer) is passed
to `g_io_extension_point_get_extensions`, it causes a segfault.

This commit adds an assertion, to prevent this.

https://bugzilla.gnome.org/show_bug.cgi?id=779183
2017-02-27 14:43:44 +00:00
Patrick Griffis
ee09bb704f gdbus-codegen: Add --output-directory flag
This is useful with Meson where files are generated in subdirs

https://bugzilla.gnome.org/show_bug.cgi?id=778801
2017-02-27 06:37:44 -05:00
Ole André Vadla Ravnås
8693d60a28 gdbusauth: plug memory leak
Happens when the waiting-for-auth state is re-entered:

SERVER_STATE_WAITING_FOR_AUTH
  |
  v
G_DBUS_AUTH_MECHANISM_STATE_REJECTED
  |
  v
SERVER_STATE_WAITING_FOR_AUTH

Causing the previous `mech` pointer to get overwritten.

https://bugzilla.gnome.org/show_bug.cgi?id=778991
2017-02-21 10:31:03 +00:00
Timm Bäder
1920b550db fdo notification: Avoid a double free
We're first getting the notification by its notify_id, but activating
the action afterwards could redraw it, leading to a dangling pointer.
Fix this by simply searching the list of active notifications again
after activating the action.
2017-02-18 10:19:18 +01:00
Patrick Griffis
79c08255be gdbus-codegen: Fix -Wconversion warning
https://bugzilla.gnome.org/show_bug.cgi?id=778581
2017-02-14 14:06:38 -05:00
Matthew Leeds
442d64ba94 gsubprocesslauncher: Clarify the behavior of set_environ()
GNOME Builder's code was assuming that setting the launcher's
environ to NULL makes the subprocess have an empty environment, but in
fact the parent process's variables are still inherited because execv is
used instead of execve when envp is NULL. This commit clarifies the
documentation to make the behavior clear.

https://bugzilla.gnome.org/show_bug.cgi?id=778422
2017-02-13 09:44:10 -06:00
Ondrej Holy
006a7d082b fileinfo: Add G_FILE_ATTRIBUTE_RECENT_MODIFIED attribute
Add filesystem attribute to propagate time, when the metadata for the file
in "recent:///" was last changed. This attribute is needed for sorting
recent backend files in client applications.

https://bugzilla.gnome.org/show_bug.cgi?id=777507
2017-02-13 08:12:48 -05:00
Ondrej Holy
453957973b fileinfo: Use monospaced font for uris
Some uris are in quotes, some in backticks, let's unify it.

https://bugzilla.gnome.org/show_bug.cgi?id=777507
2017-02-13 10:26:52 +01:00