Commit Graph

5389 Commits

Author SHA1 Message Date
Christophe Fergeau
a4012abbdf gdbus: Fix leak in g_dbus_message_print()
This leak only happens when using G_DBUS_DEBUG=message or similar, but
it's nicer to be valgrind-clean even in these cases.

https://bugzilla.gnome.org/show_bug.cgi?id=736810
2016-11-22 15:01:31 -05:00
Lukasz Skalski
59a996db9b GDBusMessage: Fix segfault if DEBUG_SERIALIZER is enabled
https://bugzilla.gnome.org/show_bug.cgi?id=729730
2016-11-22 14:59:49 -05:00
Pavel Grunt
c99fe67817 gtask: Add guards for public functions
https://bugzilla.gnome.org/show_bug.cgi?id=769745
2016-11-22 13:23:25 -05:00
Ondrej Holy
b626a4677a gunixmounts: Fix crash if path doesn't exist
g_unix_mount_for segfaults for nonexistent paths. Return NULL if path
doesn't exist.

https://bugzilla.gnome.org/show_bug.cgi?id=772160
2016-11-22 13:21:36 -05:00
Debarshi Ray
00bf553a60 GDBusMethodInvocation: Clarify how the ownership is handled
https://bugzilla.gnome.org/show_bug.cgi?id=767952
2016-11-22 17:06:48 +01:00
Benjamin Otte
578b42a2f2 glib-compile-resources: Add suggested braces
... around empty body in an 'else' statement
2016-11-20 23:50:56 +01:00
Patrick Griffis
3a8ac6e221 glib-compile-resources: Escape file names in dependency file
https://bugzilla.gnome.org/show_bug.cgi?id=774368
2016-11-20 13:33:21 -05:00
Patrick Griffis
7a8cbc60a5 glib-compile-resources: Add --generate-phony-targets flag
This includes phony targets for each dependency in the the generated
dependency file which allows building with `ninja` which doesn't like
the phony targets[1] but also allows silencing `make` errors similar to
gcc's -MP option.

[1] - https://github.com/ninja-build/ninja/issues/1184

https://bugzilla.gnome.org/show_bug.cgi?id=774368
2016-11-20 13:33:21 -05:00
Petr Kulhavy
437474318f GSocket: do not process control messages if not requested by the user
If g_socket_receive_message_with_timeout() is called with messages ==
NULL set the msg_control buffer to empty to not request the control
messages from recvmsg() at all.

This completely disables the control message processing and reduces
overhead, which might be critical at high packet rate.

https://bugzilla.gnome.org/show_bug.cgi?id=774520
2016-11-20 11:09:45 -05:00
Philip Withnall
1f36189aa5 gapplication: Fix a typo in a documentation comment
It’s ‘D-Bus’, not ‘DBus’, ‘DBUS’, ‘D Bus’, ‘Dee Buss’ or ‘the bus’.
2016-11-08 21:13:45 +00:00
Patrick Griffis
d1763d899c Revert "glib-compile-resources: Output depfile in same directory as target"
This reverts commit 9006940de6.
2016-11-05 22:15:53 -04:00
Patrick Griffis
9006940de6 glib-compile-resources: Output depfile in same directory as target
https://bugzilla.gnome.org/show_bug.cgi?id=773437
2016-11-02 17:44:23 -04:00
Matthias Clasen
2d56c49b10 Partially revert 10c490cdfe
This commit broke some tests, and I don't have the time
to fix up all the expected output, so I'll revert the changes
to the affected files for now.

This needs to be redone with the necessary test fixes.
2016-10-24 10:21:59 -04:00
Timm Bäder
f14389bec9 gapplication: Properly free the option_strings
option_strings gets set in g_application_add_main_option, so it can
contain elements independent from packed_options.

https://bugzilla.gnome.org/show_bug.cgi?id=773303
2016-10-24 06:10:57 -04:00
Patrick Griffis
243c1b7e84 glib-compile-resources: Fix creating depfile with other targets
Follow up to 87d76a5a9c from bug 745754

https://bugzilla.gnome.org/show_bug.cgi?id=773344
2016-10-24 01:41:57 -04:00
Sebastian Dröge
2a970e33a4 gresolver: Make get_default() thread-safe
https://bugzilla.gnome.org/show_bug.cgi?id=773262
2016-10-20 17:49:44 +03:00
Damien Lespiau
c494c3028c gfile: G_FILE_MONITOR_WATCH_MOVES was actually introduced in 2.46
I'm guessing the developments were done in 2.44 but the patches landed
after the 2.45.0 bump without an update to the Since tags.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=769630
2016-10-12 19:18:05 -04:00
Piotr Drąg
10c490cdfe Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772221
2016-10-12 21:30:42 +02:00
Ondrej Holy
da509fd67d gunixmounts: Add g_unix_mount_for() support
GLib has g_unix_mount_at (mount_path) already, let's add g_unix_mount_for
(file_path) for whatever path. GLib already contains some private code
for such task. Let's make this code public. This functionality is needed
by GVfs (see Bug 771431) in order to avoid copy-and-pasting.

https://bugzilla.gnome.org/show_bug.cgi?id=772160
2016-10-12 15:13:00 -04:00
Sam Thursfield
6338cde7ca glib-compile-schemas: Add a --version option
https://bugzilla.gnome.org/show_bug.cgi?id=772269
2016-10-06 21:08:25 +01:00
Sam Thursfield
bce8b6db8d glib-compile-resources: Add a --version option
There have been some improvements to the tool recently, but it's hard to
know if those are available on a given system unless the tool provides a
--version commandline option.

https://bugzilla.gnome.org/show_bug.cgi?id=772269
2016-10-06 21:08:25 +01:00
Florian Müllner
e048d31210 completion: Complete gsettings describe
Commit 8fd72838 added a 'describe' command to the gsettings tool,
but didn't implement completions for it.

https://bugzilla.gnome.org/show_bug.cgi?id=772297
2016-10-05 14:26:42 -04:00
Philip Withnall
10bac98185 gresolver: Mark GResolver as an abstract class
It only works through its virtual methods, so while it could be
instantiated before (and this is technically an API break), any instance
of it would previously have crashed as soon as any of its methods were
called anyway.

If anybody has any problems with this ABI break, please make them known
during the 2.51 unstable development cycle and it can be reverted.

https://bugzilla.gnome.org/show_bug.cgi?id=772255
2016-10-04 16:02:34 +01:00
Ondrej Holy
bd9e266e11 gunixmounts: Fix /proc/self/mountinfo monitoring
/proc/self/mountinfo is used to monitor changes of mounts with libmount.
However, GFileMonitor is used currently to monitor this file, which
doesn't work and consequently "changed" signal is never emitted. Special
monitoring needs to be used instead, same as it is used for /proc/mounts.

https://bugzilla.gnome.org/show_bug.cgi?id=662946
2016-09-29 10:21:34 +02:00
Matthias Clasen
34751ad17a Add a test for dictionaries in settings
This should clarify the questions in
https://bugzilla.gnome.org/show_bug.cgi?id=771968
2016-09-26 06:27:12 -04:00
Rico Tzschichholz
7bf31065cc gsubprocess: Fix annotation for set_environ() 2016-09-12 20:41:40 +02:00
Jeremy Whiting
8fd72838ce Added describe command to gsettings command-line tool.
describe command shows description of given gsettings key.
Added documentation of describe command to gsettings man page.
2016-08-25 12:40:27 -06:00
Philip Withnall
097f70828f gdbus-codegen: Strip @since parameters before comparison
People might put more extraneous whitespace in a @since line in a
documentation comment, which should not affect the ordering of
methods/signals/etc. in the generated output.

https://bugzilla.gnome.org/show_bug.cgi?id=770372
2016-08-25 10:27:22 +01:00
Matthias Clasen
87d76a5a9c glib-compile-resources: generate .d-file style dependency
Add --dependency-file=foo.d option to generate a gcc -M -MF style
dependency file for other build tools. The current output of
--generate-dependencies is only useful for use directly in Makefile
rules, but can't be used in other build systems like that.

The generated dependency file looks like this:
$ glib-compile-resources --sourcedir= test.gresource.xml --dependency-file=-
test.gresource.xml: test1.txt test2.txt test2.txt

test1.txt:

test2.txt:

test2.txt:

Unlike --generate-dependencies, the --dependency-file option can be
used together with other --generate options to create dependencies
as side-effect of generating sources.

Based on a patch by Tim-Philipp Müller in
https://bugzilla.gnome.org/show_bug.cgi?id=745754

The changes in this patch, compared to his are to always return
the hash table with file information from parse_resource_file, so
we can use it for dependency output, regardless if generate_dependencies
was TRUE or not.
2016-08-20 16:49:24 -04:00
Emmanuele Bassi
9afff5f05d Revert "glib-compile-resources: generate .d-file style dependency output for build tools"
This reverts commit e8c8395f0e.

Tim said that the patch isn't ready, yet, and the commit is breaking the
build in Continuous.
2016-08-20 17:16:31 +01:00
Tim-Philipp Müller
e8c8395f0e glib-compile-resources: generate .d-file style dependency output for build tools
Add --dependency-file=foo.d option to generate a gcc -M -MF style
dependency file for other build tools. The current output of
--generate-dependencies is only useful for use directly in Makefile
rules, but can't be used in other build systems like that.

The generated dependency file looks like this:
$ glib-compile-resources --sourcedir= test.gresource.xml --dependency-file=-
test.gresource.xml: test1.txt test2.txt test2.txt

test1.txt:

test2.txt:

test2.txt:

Unlike --generate-dependencies, the --dependency-file option can be
used together with other --generate options to create dependencies
as side-effect of generating sources.

Based on a patch by Tim-Philipp Müller.

https://bugzilla.gnome.org/show_bug.cgi?id=745754
2016-08-20 10:52:46 -04:00
Piotr Drąg
3f0ff576a7 Fix typos in translatable strings 2016-08-17 20:34:38 +02:00
Philip Withnall
15b315b472 gdbus-codegen: Allow '@since: UNRELEASED' in documentation comments
Previously, this would not work, as it would result in comparing the
order of a string and an integer. Make it work, and make 'UNRELEASED'
compare higher than other versions so it's always treated as the latest
version.

'UNRELEASED' is commonly used by maintainers to highlight new API while
it's being prototyped, until they know which version it will actually
be released in. At the time of release, they replace all 'UNRELEASED'
strings in git with the new version number.

An example of this usage is here:
d380ac6a2a (9208ee267cb05db1afd3a5c323d71e51db489447_7619_7656)

https://bugzilla.gnome.org/show_bug.cgi?id=769995
2016-08-16 22:36:53 +02:00
Simon McVittie
037719c27c gdbus-example-unix-fd-client: avoid strftime %c specifier
gcc 6 warns (fatally, by default) that %c only uses a 2-digit year
in some locales. The precise format does not seem to be important
for this sample code, so use ISO 8601 instead of suppressing the
warning with a pragma.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Colin Walters
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=768453
2016-08-15 14:04:43 +01:00
Philip Withnall
5cdf0efaab tests: Fix a typo on a dereferencing assignment
Otherwise the assignment is pointless. Spotted by cppcheck.
2016-08-13 10:24:23 +02:00
Philip Withnall
a42b6eab66 gresource-tool: Clarify precedence of operations
As suggested by cppcheck, which knows more than me.
2016-08-13 10:24:04 +02:00
Philip Withnall
a5044a8e78 build: Fix SystemTap build to disable semaphores as before
At some point, upstream SystemTap changed from using a
STAP_HAS_SEMAPHORES preprocessor variable for this, to using
_SDT_HAS_SEMAPHORES instead. We need to update our build system to
disable that as well.

The original discussion about use of semaphores is here:

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

This was breaking the build with -flto enabled, either because -flto
doesn’t work with semaphores.

https://bugzilla.gnome.org/show_bug.cgi?id=768198
2016-08-13 09:32:12 +02:00
Philip Withnall
0e3f968a2e gio: Fix use of Docbook in documentation comment
This is literally so last year.
2016-08-12 15:58:39 +02:00
Philip Withnall
04bbf9df37 gdatagrambased: Clarify that connection-oriented ≠ stream-based
GDatagramBased allows connection-oriented and connection-less sockets,
but does not allow stream-based sockets (because it’s datagram-based).
So it supports SCTP and UDP, but not TCP.

Clarify that in the documentation, and people sometimes confuse
connection-oriented with stream-based, due to the prevalence of TCP.
2016-08-03 18:46:29 +01:00
Mario Sanchez Prada
ed75b1623d gunixmounts: Ensure that libmount's context gets freed on early returns
Otherwise, it will be leaked in case the relevant table (mtab, fstab)
could not be retrieved for some reason.

https://bugzilla.gnome.org/show_bug.cgi?id=769238
2016-07-28 08:24:57 -06:00
Mario Sanchez Prada
b28c76b0d8 gunixmounts: Do not leak libmount tables in _g_get_unix_mounts()
Use mnt_context_get_mtab instead of using mnt_context_get_table(), since
that's the recommended way of accessing mtab/mountinfo information, and
also because that way the (struct libmnt_table *) will get automatically
deallocated when calling mnt_free_context()

https://bugzilla.gnome.org/show_bug.cgi?id=769238
2016-07-28 08:24:57 -06:00
Chun-wei Fan
48317b199b gio/gappinfo.c: Include gtask.h
This avoids warning/error C4013 (aka implicit declaration of ...) as we
need APIs from gtask.h.
2016-07-27 16:06:21 +08:00
Matthias Clasen
c1e8f705dd Add async variant of g_app_info_launch_default_for_uri
This is useful in the portalized case, when the portal may
present an app chooser dialog to the user.

https://bugzilla.gnome.org/show_bug.cgi?id=768752
2016-07-26 16:05:29 -04:00
Mario Sanchez Prada
f885c4dd0d Monitor /proc/self/mountinfo when using libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
97f799b53a Refactor common code into create_unix_mount_point ()
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
44f4309e3b Implemented _g_get_unix_mount_points() based on libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
2051ee7678 Refactor common code into create_unix_mount_entry ()
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
030594777a Implemented _g_get_unix_mounts() based on libmount
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
8d5cf2df10 Use libmount to find the path of the fstab file
https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Mario Sanchez Prada
4f9cddaeb8 Added autotools support for libmount
Check whether libmount is available at configuration time and provide
an option to explicitly enable or disable it, similar to libelf.

https://bugzilla.gnome.org/show_bug.cgi?id=522053
2016-07-26 08:09:27 -06:00
Emilio Pozuelo Monfort
38317cf746 Use a uint64 to unpack a 64 bit value
https://bugzilla.gnome.org/show_bug.cgi?id=769089
2016-07-22 19:20:30 +02:00
Matthias Clasen
d5efa64539 Deal with lack of O_CLOEXEC
Some platforms don't have it. We fall back to fcntl() in other
places, so do it here as well.

https://bugzilla.gnome.org/show_bug.cgi?id=769042
2016-07-21 11:54:14 -04:00
Matthias Clasen
db0bf5bbf1 proxy resolver portal: Fix the async api 2016-07-20 20:42:09 -04:00
Dan Winship
6de5595570 Fix gio/tests/socket-listener
g_socket_listener_add_address() is synchronous; all of the events will
have been emitted before it returns and it doesn't queue any sources.
The test was unintentionally depending on the fact that
g_main_context_iterate(NULL, TRUE) would return anyway (at least the
first time it was called), but that's no longer true after e4ee307.

https://bugzilla.gnome.org/show_bug.cgi?id=768968
2016-07-19 17:22:07 -04:00
Emmanuele Bassi
7e40228cae Update the ignore file for GIO 2016-07-19 14:18:49 +01:00
Chun-wei Fan
97972471ca gio/glocalfile.c: Windows: Define ECANCELED if not already defined
Older Visual Studio may not have it defined, so define it like what is
defined for Visual Studio 2010 and later.
2016-07-18 14:41:17 +08:00
Chun-wei Fan
c6aee1bf15 Visual Studio builds: Build the gio tool
https://bugzilla.gnome.org/show_bug.cgi?id=768357
2016-07-18 10:39:20 +08:00
Christian Persch
8345a42cd0 Recognise common C++ extension for automatic target selection
glib-compile-resources --generate is supposed to automatically detect
whether to generate source code or header from the target's file extension.
However, this only worked for C; extend this to include the canonical
C++ filename extensions. Also make the check case insensitive.

https://bugzilla.gnome.org/show_bug.cgi?id=747134
2016-07-16 23:30:46 -04:00
Lars Uebernickel
0e5e3d0d65 gsettings: clarify changed signal documentation
Make it clear that this signal is only guaranteed to be emitted when a
key has been read before.

https://bugzilla.gnome.org/show_bug.cgi?id=750257
2016-07-16 23:26:56 -04:00
Ismo Puustinen
9864c8abf5 gio: properly free memory, preventing leak and illegal access.
https://bugzilla.gnome.org/show_bug.cgi?id=753231
2016-07-16 23:24:39 -04:00
Matthias Clasen
3c861237fb Convince gcc to compile this code
It shouldn't be that hard.
2016-07-16 23:24:39 -04:00
Matthias Clasen
21ceeed3b9 Improve error reporting
Include the filename for the file in question in many of the
error messages in glocalfile.c. This is useful information when
diagnosing such errors, so make it easily available.

http://bugzilla.gnome.org/show_bug.cgi?id=754012
2016-07-16 23:09:09 -04:00
Chun-wei Fan
b08a8dc949 gio tool: Fix build on Windows/non-GCC
The recently-added GIO tools is intended to be built on all platforms, so
adjust the code a bit to enable this:

-Use gssize instead of ssize_t, as ssize_t is not supported by all
 compilers.
-Include io.h on Windows, and define STDIN_FILENO and STDOUT_FILENO if
 necessary on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=768357
2016-07-16 23:03:48 -04:00
Ryan Lortie
ca03753853 g_settings_reset(): add precondition checks
Ensure that @key is non-%NULL on g_settings_reset().

It turns out that using g_settings_reset() with %NULL key (although
invalid as per the API documentation and not possible via bindings)
accidentally produces the same effect as the _reset_all() API that we
are about to add.

Add the standard precondition checks to prevent that from happening.

https://bugzilla.gnome.org/show_bug.cgi?id=744678
2016-07-16 22:26:43 -04:00
Milan Crha
4215c0ce91 Fix memory leaks in GNetworkMonitorNetlink
As claimed by valgrind in a downstream bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1317369

https://bugzilla.gnome.org/show_bug.cgi?id=766933
2016-07-16 21:15:30 -04:00
Olivier Crête
e3e3ed0d7d socketservice: Document that it starts pre-activated.
https://bugzilla.gnome.org/show_bug.cgi?id=728207
2016-07-16 21:12:06 -04:00
Aurélien Zanelli
b121a7916d gio/tests/gsettings: fix GSettings reference leaks in some tests
GSettings objects were not unreffed in test_flags, test_enums and
test_ranges tests and when we skip internationalization tests, ie
test_l10n(_context).

https://bugzilla.gnome.org/show_bug.cgi?id=768560
2016-07-16 20:57:20 -04:00
Jonatan Pålsson
1e3f2ba415 docs: Remove superflous XML comments in doc string for GDBusProxyTypeFunc
https://bugzilla.gnome.org/show_bug.cgi?id=766899
2016-07-16 20:49:52 -04:00
Stephan Bergmann
e7478ec967 Swallow -- argument when necessary
https://bugzilla.gnome.org/show_bug.cgi?id=768806
2016-07-16 20:34:51 -04:00
Simon McVittie
0f2e4fd01c Do not attempt to autolaunch a session dbus-daemon with no DISPLAY
The two known use-cases for autolaunching are:

* X-forwarding: "ssh -Y myhost myapp" resulting in a
  session bus on myhost but an X server on the original host

* Legacy desktop environments on OSs without D-Bus integration:
  e.g. running a single GNOME or KDE app under fvwm or something,
  without a session dbus-daemon being started by either systemd,
  gnome-session, or OS integration scripts analogous to Debian's
  /etc/X11/Xsession.d/75dbus_dbus-launch

In either case, an X11 DISPLAY is also needed.

"dbus-launch --autolaunch" doesn't do anything useful when unable
to connect to an X11 display; this has been the case since the feature
was added in 2006, and is useful to avoid "split brain" situations in
which two processes that ought to be part of the same session end up
on separate session buses. Since dbus commit 407c111 in 2011,
libdbus hasn't even attempted to run "dbus-launch --autolaunch"
unless getenv("DISPLAY") returns non-null in the parent: this avoids
doing a relatively complicated fork-and-exec that is clearly not
going to lead to success. This commit gives GDBus the same policy.

This change was originally made to work around a race condition in
subprocess spawning (Debian bug #737380, GNOME bug #711090) but
it seems valid in its own right.

In my opinion as D-Bus maintainer, "dbus-launch --autolaunch" should
be considered to be an X11 feature, and any future D-Bus enhancements
(e.g. kdbus) or successors for X11 (e.g. Wayland, Mir) should obtain
a session bus address by other means - either a session manager
such as "systemd --user", gnome-session or Upstart, or a wrapper
for the user session like dbus-run-session(1).

Related to dbus bug <https://bugs.freedesktop.org/show_bug.cgi?id=19997>.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=723506
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=737380
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-07-16 20:33:34 -04:00
Ting-Wei Lan
cef799377e gio-querymodules: Call setlocale in main function
It is required to correctly show translated messages on some locales.

https://bugzilla.gnome.org/show_bug.cgi?id=760423
2016-07-14 11:25:42 +08:00
Matthias Clasen
63654183a8 documents portal: Make sure O_PATH is defined
FreeBSD doesn't have it.

https://bugzilla.gnome.org/show_bug.cgi?id=768780
2016-07-13 12:38:22 -04:00
Chun-wei Fan
b5258d9d76 gio: Build the portal code only on *NIX
xdg-desktop-portal support is only usable on *NIX platforms, so don't build
them on non-*NIX platforms.  Also clean up gio/Makefile.am a bit to split out
the listings for the platform-specific sources from the platform-neutral
sources, and assemble them for the final list of sources required for libgio.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-13 10:43:05 +08:00
Chun-wei Fan
bb5707d6cb gio/Makefile.am: Rearrange things a bit
Move the gio tool build items up, so that the MSVC items do not get split
by it.
2016-07-13 10:41:16 +08:00
Cosimo Cecchi
bc7c030480 documentportal: print warnings when document portal fails to initialize
Instead of siletly failing or calling a method on a NULL instance.
2016-07-12 15:12:35 -07:00
Philip Withnall
e694d1b673 gio: Fix a memory leak in gportalsupport.c
Coverity CID: 1357527
2016-07-12 23:08:27 +01:00
Dan Winship
e0bb25c214 Remove an erroneous check in the non-sendmmsg() version of g_socket_send_messages()
The docs specify that *all* errors are ignored if we managed to send
any data successfully, not just timeout/wouldblock.

https://bugzilla.gnome.org/show_bug.cgi?id=768549
2016-07-12 09:14:09 -04:00
Cosimo Cecchi
62bd8f54bb appinfo: support opening files through document portal
In addition to URIs, we now also support opening files internal to the
sandboxed application through the document portal.
2016-07-11 18:20:48 -07:00
Cosimo Cecchi
f4e2047f20 build: don't forget to clean generated portal files 2016-07-11 18:20:48 -07:00
Dan Winship
79b7efada3 Fix gio/tests/inet-address on OS X
OS X apparently stringifies the IPv6 address "::80" as "::0.0.0.128",
which is bizarre, but that address *is* in a "reserved for future use"
range, so it's not unambiguously wrong I guess. Anyway, fix the text
to use an address everyone can agree on.

https://bugzilla.gnome.org/show_bug.cgi?id=768551
2016-07-11 17:42:41 -04:00
Philip Withnall
a9172c6d03 gio-tool: Fix memory leaks on error paths in mount command
Various GErrors were being leaked.

Coverity CID: 1357351 (amongst others)
2016-07-11 21:56:04 +01:00
Philip Withnall
996bb34986 gio-tool: Remove a stray semicolon
This meant the help text would always be outputted, rendering
the same mode useless and the code below it dead.

Coverity CID: 1357352
2016-07-11 21:47:49 +01:00
Chun-wei Fan
d896ad269e gio/gappinfo.c: Don't include unistd.h
Functions from unistd.h seems not to be used in commit 5b77a19, and
unistd.h is not universally available, so don't include it.
2016-07-11 15:18:09 +08:00
Matthias Clasen
bd3fb2a15f Add a portal backend for GNotification
This talks to the org.freedesktop.portal.Notification portal
instead of directly to gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Matthias Clasen
e362a01446 Add a portalized proxy resolver implementation
The backend for this lives in xdg-desktop-portal,
and is in turn using GProxyResolver.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Matthias Clasen
cea5626c49 Add a portalized network monitor implementation
The backend for this lives in xdg-desktop-portal,
and is in turn using GNetworkMonitor.

When network is not available in the sandbox, there is
no point in reporting accurately about the network
status outside the sandbox. Just return 'no connection'
in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Matthias Clasen
5b77a19fe1 Add portal support to g_app_info_launch_default_for_uri
We need to patch in the portal support at a high enough
level that GAppInfo is not involved - a sandboxed app may
not be able to see any applications, so it can only launch
the defaults.

Note that even though the API is called launch_default...,
the portal may still offer the user to choose the application
to launch.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:47:36 -04:00
Matthias Clasen
78ef32110a Add portal helpers
These are private helper functions that will be used in
the following commits to get information about whether
we are running in a flatpak sandbox, etc.

We allow the use of GTK_USE_PORTAL=1 in the environment
to force the use of portals. This can be useful for
testing and debugging portal interaction.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:44:43 -04:00
Kalev Lember
4586434346 GFileMonitor: Fix doc typos 2016-07-06 14:37:12 +02:00
Matthias Clasen
9edba4e49c Add a new gio commandline tool
This command collects the various commandline utilities that
are currently shipped in gvfs, and unifies them under a single,
command-style binary.

The tools just use GIO APIs, so it makes sense for them to live here.
2016-07-01 16:01:34 -04:00
Philip Withnall
3613b7a366 gio: Add source tags to various GTasks constructed in GLib
This makes them easier to identify when debugging and profiling.

This patch was somewhat less than interesting to write.

https://bugzilla.gnome.org/show_bug.cgi?id=767765
2016-06-29 15:16:52 +01:00
Philip Withnall
8c6d08ab1b build: Simplify dtrace configuration
Apply the same changes as in commit
7563ab4734 to gio/Makefile.am.

https://bugzilla.gnome.org/show_bug.cgi?id=725902
2016-06-29 15:10:12 +01:00
Philip Withnall
c4695f192c build: Rename SystemTap scripts to include the LT version
In a vague attempt at ensuring the .stp scripts can be closely
associated with the .so files which they hard-code references to, rename
the scripts so they include the LT version — so that they are the .so
file name plus .stp.

This does not fix the fact that our .stp scripts will not work on
multiarch systems, as they are installed in an architecture-independent
directory (/usr/share/systemtap/tapset). At the moment, it is
recommended that any distribution who package the .stp files should
install them in the architecture-specific subdirectories of this (for
example, /usr/share/systemtap/tapset/x86-64).

A better long-term solution for this is under discussion upstream:
https://sourceware.org/bugzilla/show_bug.cgi?id=20264

https://bugzilla.gnome.org/show_bug.cgi?id=662802
2016-06-29 14:43:52 +01:00
Philip Withnall
c9d661b431 build: Ensure gio.stp.in is always distributed
Even if systemtap is not enabled in configure when running distcheck.

https://bugzilla.gnome.org/show_bug.cgi?id=662802
2016-06-29 14:43:51 +01:00
Florian Müllner
61c1e2db99 vfs: Fix copying default schemes list
The list of supported schemes is not known at compile-time, so it is
wrong to iterate the list with G_N_ELEMENTS() and we miss all but the
first scheme. Fix by checking for the %NULL sentinel instead.

https://bugzilla.gnome.org/show_bug.cgi?id=768119
2016-06-28 15:57:49 +02:00
Florian Müllner
a42bdecf5c vfs: Fix return value of get_supported_uri_schemes()
The function is expected to return a %NULL-terminated array, but
commit 375b4ca65c dropped the sentinel when adding support for
additional custom schemes. Add it back.

https://bugzilla.gnome.org/show_bug.cgi?id=768119
2016-06-28 15:57:49 +02:00
Ondrej Holy
e57355b055 fileinfo: Add G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE attribute
Add filesystem attribute to detect remote filesystems in order to
replace hardcoded filesystem types in GtkFileSystem. Set this attribute
also for GLocalFile appropriately.

Bump version to 2.49.3, so that early adopters of new API have a version
number to target.
2016-06-28 10:28:51 +02:00
Ernestas Kulik
f4b5dc30a7 gvfs: fix possible infinite loop in parse_name_internal()
If none of the closures in the hash table return a non-null value, the
loop never ends. Since the end of the hash table has been reached at
that point, g_hash_table_iter_next() starts asserting.

The possible fix is making the return value of g_hash_table_iter_next()
the condition in the loop.

https://bugzilla.gnome.org/show_bug.cgi?id=768029
2016-06-25 08:44:52 -04:00
Cosimo Cecchi
375b4ca65c vfs: add g_vfs_register_uri_scheme()
Add a new API to allow clients to register a custom GFile implementation
handling a particular URI scheme.
This can be useful for tests, but also for cases where a different URI
scheme is desired to be used with another custom GFile backend.

As an additional cleanup, we can use this to register the "resource" URI
scheme too.

Based on a patch by Jasper St. Pierre <jstpierre@mecheye.net>.

https://bugzilla.gnome.org/show_bug.cgi?id=767887
2016-06-25 06:58:19 +08:00
Allison Lortie
9bb2499c9c tests: fix uint64 argument to g_object_set() call
5cea1c861d introduced accessors for 64bit
ints to gsettings, at which point the testcases were expanded.

Unfortunately, the expanded tests contained a bug: integer constants
passed to g_object_set() for a 64-bit property need an up-cast.  Add
that now.

Problem found by Iain Lane.
2016-06-23 11:49:39 -04:00
Philip Withnall
8e21b9e966 build: Add gio_probes.d to sources list so it ends up in the tarball
The probes.d file should be distributed even if GLib is build with
dtrace disabled. This is what’s done in the glib and gobject
directories.
2016-06-22 12:41:34 +01:00
Philip Withnall
fadd00c708 glocalfileoutputstream: Drop unnecessary (void) return value casts
g_close() does not have G_GNUC_WARN_UNUSED_RESULT, so these casts are
unnecessary.
2016-06-16 14:45:21 -04:00
Philip Withnall
16d674411f glocalfileoutputstream: Fix an FD leak in an error path
If a backup file is created, opened successfully, then fstat() on it
fails (perhaps due to another process deleting it in the mean time?),
the FD will be leaked.

Coverity issue: #1159485

https://bugzilla.gnome.org/show_bug.cgi?id=730187
2016-06-16 14:39:05 -04:00
Philip Withnall
195a0cb6bb gio: Add SystemTap and DTrace probes for GTask
This adds a basic tapset for GIO, covering various interesting parts of
GTask.

https://bugzilla.gnome.org/show_bug.cgi?id=759813
2016-06-15 16:15:12 -04:00
Philip Withnall
b26b083aa2 gio: Support using GDBusObjectManagerServer at path ‘/’
Previously this would cause an assertion failure when checking the paths
of exported objects, as it would try to check that their paths started
with ‘//’ due to mishandling the root object case.

Includes a unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=761810
2016-06-15 13:27:19 -04:00
Philip Withnall
ac1166626c gio: Add missing (type filename) annotations
These differentiate between strings in the GLib filename encoding, and
strings in UTF-8.

https://bugzilla.gnome.org/show_bug.cgi?id=700756
2016-06-15 11:04:18 -04:00
Philip Withnall
f8ff1049d3 gio: Add missing (nullable) annotation
Add it to g_application_command_line_get_cwd(). Also add a clarifying
internal comment about the cwd private member.

https://bugzilla.gnome.org/show_bug.cgi?id=700756
2016-06-15 11:03:55 -04:00
Hans Petter Jansson
ae048625fe GDbusProxy: Plug memory leak.
proxy->priv->name_owner gets overwritten in async_init_data_set_name_owner() on the
assumption that it will always be NULL when we get there. However,
on_name_owner_changed() can run first, and it does set name_owner.

==20126== 42 bytes in 6 blocks are definitely lost in loss record 15,174 of 48,256
==20126==    at 0x4C280F3: malloc (vg_replace_malloc.c:299)
==20126==    by 0x7541D00: g_malloc (gmem.c:104)
==20126==    by 0x7558FEE: g_strdup (gstrfuncs.c:364)
==20126==    by 0x6DF8E4F: on_name_owner_changed (gdbusproxy.c:1399)
==20126==    by 0x6DE94C4: emit_signal_instance_in_idle_cb (gdbusconnection.c:3743)
==20126==    by 0x753C315: g_main_dispatch (gmain.c:3066)
==20126==    by 0x753C315: g_main_context_dispatch (gmain.c:3642)
==20126==    by 0x753C667: g_main_context_iterate.isra.24 (gmain.c:3713)
==20126==    by 0x753CA69: g_main_loop_run (gmain.c:3907)
==20126==    by 0x5E38000: meta_run (main.c:556)
==20126==    by 0x401EC0: main (main.c:441)

https://bugzilla.gnome.org/show_bug.cgi?id=755439
2016-06-15 16:39:00 +02:00
Christoph Reiter
9ec74d20a7 Partly revert "gio: Add filename type annotations"
Revert all annotation changes for environment variables and command line
arguments.

See commit f8189ddf98.
2016-06-07 19:50:03 +02:00
Christoph Reiter
f8189ddf98 gio: Add filename type annotations
https://bugzilla.gnome.org/show_bug.cgi?id=767245
2016-06-04 20:38:42 +02:00
Emmanuele Bassi
7d8e98ee09 Fix paths for non-srcdir builds
This fixes a build failure in Continuous that resulted in the error:

../../../gio/tests/test.gresource.xml: Failed to locate
'test-generated.txt' in any source directory.
Makefile:4676: recipe for target 'test.gresource' failed
make[6]: *** [test.gresource] Error 1
2016-06-04 13:49:46 +01:00
Georges Basile Stavracas Neto
5411a187a3 glib-compile-resources: correct resource compiler dependency for generated files
Don't require that files can be resolved when generating dependencies.

Original patch by Garret Regier.

https://bugzilla.gnome.org/show_bug.cgi?id=673101
2016-06-04 08:24:22 -04:00
Krzesimir Nowak
f5e875b2f8 gio: Add a missing autocleanup for GFileAttributeInfoList 2016-06-03 12:36:39 +02:00
Matthias Clasen
15a85f2095 GCredentialsType: Remove XML markup from docs
We now use markdown.
2016-06-02 13:26:07 -04:00
Krzesimir Nowak
504f189e59 gfileenumerator: Fix typo in docs
This probably used to be a part of libgsystem.
2016-06-02 11:29:55 +02:00
Ondrej Holy
17e5281ca9 Fix ABI compatibility
Commit 7b3f6da broke ABI compatibility, because of newly added vfunc.
Move the vfunc to the end to ensure ABI compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=765924
2016-05-20 12:35:06 +02:00
Ondrej Holy
7b3f6da307 gio: Add g_drive_is_removable() support
Nautilus wants to show entries in the sidebar only for removable devices.
It uses currently sort of conditions to determine which devices should be
shown. Those condition fails in some cases unfortunatelly. Lets provide
g_drive_is_removable() which uses udisks Removable property to determine
which devices should be shown. It should return true for all drives with
removable media, or flash media, or drives on usb and firewire buses.

https://bugzilla.gnome.org/show_bug.cgi?id=765900
2016-05-20 10:31:22 +02:00
Руслан Ижбулатов
2aa7338875 testsuite: override check-TESTS target in gio tests subdir
This prevents testsuite from trying to build any TESTS in that
subdirectory, which will fail, because there are no TESTS defined
in that Makefile.am.

This happens when user runs make check TESTS=...

https://bugzilla.gnome.org/show_bug.cgi?id=766407
2016-05-14 04:59:40 +00:00
Matthias Clasen
98f86beed6 gdbus-codegen: Only generate autocleanup when instructed to
This adds a new --c-generate-autocleanup option to gdbus-codegen
which can be used to instruct gdbus-codegen about what autocleanup
definitions to emit.

Doing this unconditionally was found to interfere with existing
code out in the wild.

The new option takes an argument that can be
none, objects or all; to indicate whether to generate no
autocleanup functions, only do it for object types, or do it
for interface types as well. The default is 'objects', which
matches the unconditional behavior of gdbus-codegen on the 2.48
branch.

https://bugzilla.gnome.org/show_bug.cgi?id=763379
2016-05-05 06:13:16 -04:00
Chun-wei Fan
217b620a7b gresource.c: Use g_file_test()
Use the g_file_test() API instead of the g_stat() + S_ISDIR combo to fix
builds on compilers that do not support S_ISDIR.

https://bugzilla.gnome.org/show_bug.cgi?id=765991
2016-05-04 23:50:18 +08:00
Christian Hergert
c16a0b53fe socket: set fd field to -1 after closing socket
This ensures that g_socket_get_fd() will return -1 after the socket has
been closed.

https://bugzilla.gnome.org/show_bug.cgi?id=765959
2016-05-04 16:47:54 +03:00
Debarshi Ray
0cd3d5741b gio/tests/task: Ensure that g_task_had_error doesn't forget the error
https://bugzilla.gnome.org/show_bug.cgi?id=764163
2016-05-04 09:34:05 +02:00
Debarshi Ray
a17e1e6d19 gtask: Don't forget about the error after g_task_propagate_*
The use of past tense in g_task_had_error makes one assume that it
won't forget about any errors that might have occurred. Except, in
reality, it would.

Let's use a boolean flag to remember the error once it's been
propagated, as opposed to keeping the error around. This ensures that
the g_task_propagate_* methods continue to give invalid results when
called more than once, as mentioned in the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=764163
2016-05-04 09:33:49 +02:00
Simon McVittie
1c6cd5f0a3 codegen: make g_autoptr for the GInterface conditional
Some GNOME projects unconditionally work around the generated code's
lack of g_autoptr support by defining the autoptr cleanup function
themselves, which is not forward-compatible; as a result, commit
cbbcaa4 broke them. Do not define the cleanup function unless the
including app "opts in" to newer APIs via GLIB_VERSION_MAX_ALLOWED.

Projects requiring compatibility with GLib < 2.49 can get a
forward-compatible g_autoptr for a generated GInterface type found in
a library, for example ExampleAnimal in the GIO tests, by declaring
and using a typedef with a distinct name outside the library's
namespace:

    typedef AutoExampleAnimal ExampleAnimal;
    G_DEFINE_AUTOPTR_CLEANUP_FUNC (AutoExampleAnimal, g_object_unref)

    ...

    g_autoptr (AutoExampleAnimal) animal = NULL;

    /* returns ExampleAnimal * */
    animal = example_animal_proxy_new_sync (...);
    /* takes ExampleAnimal * first argument */
    example_animal_call_poke_sync (animal, ...);

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=763379
Reviewed-by: Colin Walters <walters@verbum.org>
Reviewed-by: Emmanuele Bassi <ebassi@gnome.org>
2016-05-03 15:48:55 +01:00
Simon McVittie
cbbcaa4dd7 codegen: Add g_autoptr support for the shared GInterface
The rest of the generated classes gained g_autoptr support in fd6ca66,
but this one is still missing. Because whatever_proxy_new_finish() and
whatever_proxy_new_sync() are declared as returning a Whatever *
instead of a WhateverProxy *, and the generated method-call stubs
act on a Whatever *, it's reasonably common to want to declare a
g_autoptr (Whatever).

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/review?bug=763379
Reviewed-by: Colin Walters <walters@verbum.org>
2016-05-02 19:59:09 +01:00
Christian Hergert
d95030a2fd task: avoid context lock when setting source name
If you set the source name after attaching to the context, you have to
lock the context to free/assign the new source name.

https://bugzilla.gnome.org/show_bug.cgi?id=765861
2016-04-30 15:18:31 -07:00
Allison Ryan Lortie
05060b6194 gdbus-tool: avoid irrelevant note about arg types
gdbus-tool prints a hint about the expected arguments to a function call
in case of errors.  Unfortunately, it prints this message on all errors.
I've seen this confuse users several times -- they go on tweaking the
arguments trying to get the correct type, even though they had it
correct in the first place.

Let's limit the hint to the case where it was actually invalid arguments
that triggered the problem.  Also, adjust the code that prints the
message so that it will also report on the case that no arguments were
expected.

We could possibly get closer to what we want by comparing the list of
expected arguments with the parameter list, as it was parsed from the
user, but that would involve composing the expected type.  Let's keep
this simple for now.

https://bugzilla.gnome.org/show_bug.cgi?id=765710
2016-04-29 10:36:53 +02:00
Marc-Antoine Perennou
5cea1c861d gsettings: add get/set_{,u}int64
https://bugzilla.gnome.org/show_bug.cgi?id=755898

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2016-04-28 17:28:44 +02:00
Allison Ryan Lortie
55ab3af098 GResources: add support for resource overlays
When debugging a program or testing a change to an installed version, it
is often useful to be able to replace resources in the program or a
library, without recompiling.

To support this, for debugging and hacking purposes, it's now possible
to define a G_RESOURCE_OVERLAYS environment variable as a
colon-separated list of substitutions to perform when looking up
GResources.

A substitution has the form

  "/org/gtk/libgtk=/home/desrt/gtk-overlay"

The part before the '=' is the resource subpath for which the overlay
applies.  The part after is a filesystem path which contains files and
subdirectories as you would like to be loaded as resources with the
equivalent names.

In the example above, if an application tried to load a resource with
the resource path '/org/gtk/libgtk/ui/gtkdialog.ui' then GResource would
check the filesystem path '/home/desrt/gtk-overlay/ui/gtkdialog.ui'.  If
a file was found there, it would be used instead.

Substitutions must start with a slash, and must not have a trailing
slash before the '='.  It is possible to overlay the location of a
single resource with an individual file.

https://bugzilla.gnome.org/show_bug.cgi?id=765668
2016-04-28 14:36:13 +02:00
Allison Ryan Lortie
3c7c0af1c9 GResources: use g_hash_table_get_keys_as_array()
Replace the hand-written equivalent of this with the call to the
GHashTable built-in version to save a few lines of code.

The GResource code was written a couple of years before this function
existed.

Similarly, replace a set-mode usage of g_hash_table_insert() with a call
to g_hash_table_add().

https://bugzilla.gnome.org/show_bug.cgi?id=765668
2016-04-28 14:36:13 +02:00
Philip Chimento
f8f344923e tests: Fix appmonitor test
Commit f45ec47 fixed a race condition in this test, but one change was
omitted; maybe lost in a rebase.

https://bugzilla.gnome.org/show_bug.cgi?id=749606
2016-04-27 12:12:31 +08:00
Allison Ryan Lortie
75589956a4 GContextSpecificGroup: add testcase
Add a test case for unreffing an object from a GContextSpecificGroup
immediately after firing a signal, before allowing the mainloop to run.

https://bugzilla.gnome.org/show_bug.cgi?id=762994
2016-04-26 15:20:16 +02:00
Allison Ryan Lortie
62f320e6bb GContextSpecificGroup: detach sources
GContextSpecificGroup has been somewhat broken for a rather long time:
when we remove the last reference on an object held in the group, we try
to clean up the source, but fail to actually remove it from the
mainloop.

We will soon stop emitting signals on the source (due to it having been
removed from the hash table) but any "in flight" signals will still be
delivered on the source, which continues to exist.  This is a problem if
the event is being delivered just as the object is being destroyed.

This also means that we leave the source attached to the mainloop
forever (and next time will create a new one)...

This is demonstrated with the GtkAppChooser dialog which writes an
update to the mimeapps.list file just as it is closing, triggering the
app info monitor to fire just as it is being destroyed.

Karl Tomlinson correctly analysed the problem and proposed this fix.

https://bugzilla.gnome.org/show_bug.cgi?id=762994
2016-04-26 15:20:16 +02:00
Allison Ryan Lortie
3301b852a2 GDesktopAppInfo: support bus activation with '-'
GApplication has accepted any valid bus name as an application ID since
before the time of D-Bus activation.  This includes bus names with '-'.
Several applications have even attempted support bus activation with
these names, going as far as installing D-Bus service files, without
realising that they are silently falling back to fork()/exec() on
account of the name containing a dash.

The reason for the problem is that D-Bus object paths cannot contain
dashes.  We solved this problem privately in an unspecified way inside
of GApplication but substituting '_' in this case, but never made this
part of the Desktop Entry Specification.

The fact that these apps with '-' in the desktop file names aren't
actually using D-Bus activation is beside the point: their intent here
was clear.  Let's avoid forcing them to rename their desktop files again
by simply accepting '-' in desktop file names and munging the path in
the way that GApplication did so historically.

The new path escaping code here has been copied more or less verbatim
from GApplication's own code for the same purpose, with only the removal
of one irrelevant part.

An update to the desktop entry specification will follow.

https://bugzilla.gnome.org/show_bug.cgi?id=764754
2016-04-25 09:19:23 +02:00
Antoine Jacoutot
52f116e874 gioenums.h: Remove trailing comma.
This is helpful to people using the g++ --pedantic option.
2016-04-17 10:04:13 +02:00
Matthias Clasen
24b0781264 Improve GApplication docs
D-Bus activation is a thing now; bring the local_command_line
docs in sync with reality.
2016-04-13 12:01:49 -04:00
Debarshi Ray
fcaa3fb189 docs: Add Since for handle_local_options
https://bugzilla.gnome.org/show_bug.cgi?id=764685
2016-04-11 22:37:35 -04:00
Sébastien Wilmet
d16abd3df3 docs: fix function name
g_action_parse_detailed_action_name() doesn't exist, it's
g_action_parse_detailed_name() instead.
2016-04-09 13:01:53 +02:00
Cosimo Cecchi
f45ec47be1 tests: always remove app.desktop
https://bugzilla.gnome.org/show_bug.cgi?id=749606
2016-04-03 12:23:21 -07:00
Philip Withnall
d09c219696 glocalfile: Assert against a potential NULL pointer dereference
This was confusing some static analysis. Through canonicalize_filename()
at construction time, we guaranteed that ->filename is canonical and
absolute, so g_path_skip_root() should never fail.

https://bugzilla.gnome.org/show_bug.cgi?id=731988
2016-04-02 12:27:05 +01:00
Iain Lane
a668ee8fe9 giotypefuncs.c: Sort _get_type functions in the 'C' locale
This ensures that the generated file is always the same (not dependent
on the build machine's environment), making the build reproducible.

Thanks to Jérémy Bobbio <lunar@debian.org> for the Debian bug report and
patch.

https://bugzilla.gnome.org/show_bug.cgi?id=763617
2016-03-21 13:44:38 +00:00
Philip Withnall
c7763d0712 glib-compile-resources: Fix minor memory leak on error path
Spotted by Coverity (CID: #1353385).
2016-03-21 12:44:15 +00:00
Philip Withnall
db972a73ce gio: Fix a GError memory leak in GNetworkService
Spotted by Coverity (CID: #1325405).
2016-03-15 18:08:29 +00:00
Philip Withnall
27660b178e gio: Fix a GError memory leak in GDesktopAppInfo
Spotted by Coverity (CID: #1352961).
2016-03-15 18:03:00 +00:00
Philip Withnall
0a580fc79e gio: Fix minor typo in GActionGroup documentation 2016-03-14 12:57:20 +00:00
Philip Withnall
fd6ca66c16 codegen: Add support for g_autoptr to gdbus-codegen–generated objects
This means that any code generated by gdbus-codegen will now require
GLib 2.44 or newer.

https://bugzilla.gnome.org/show_bug.cgi?id=763379
2016-03-10 09:39:44 +00:00
Руслан Ижбулатов
74b1dd87b5 W32: eliminate busy cursor when a rundll32-hosted child runs
Even though GetStartupInfo() in g_win32_run_session_bus() would
tell us that STARTF_FORCEONFEEDBACK flag is not set, it still
affects the rundll32 process for some reason.

This means that Windows WM changes mouse cursor to IDC_APPSTARTING for
a few seconds when rundll32 runs g_win32_run_session_bus(). Since
g_win32_run_session_bus() never satisfies the conditions set by
STARTF_FORCEONFEEDBACK, the busy cursor only goes away after a
timeout.

Fix this by explicitly running GetMessage(). To ensure that GetMessage()
doesn't block, post a quit message immediately before calling it.

https://bugzilla.gnome.org/show_bug.cgi?id=760694
2016-03-03 07:26:04 +00:00
Jan Alexander Steffens (heftig)
5a894c3232 gsettings: Don't crash when no schemas are installed
Still doesn't behave well ("gsettings help" causes an error),
but at least there's no segfault anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=724847
2016-03-02 19:04:28 -05:00
Allison Ryan Lortie
b54acf513d GDBusConnection: use uint for bitshifts
"1 << 31" is not well-defined, do use "1u << 31" instead.

https://bugzilla.gnome.org/show_bug.cgi?id=762748
2016-03-01 10:34:07 -05:00
Ignacio Casal Quinteiro
96fb3b9c03 gwin32fsmonitorutils: avoid useless cast 2016-03-01 08:55:29 +01:00
Ignacio Casal Quinteiro
6e454a99ef gwin32fsmonitorutils: avoid a possible invalid memory access 2016-03-01 08:55:26 +01:00
Ignacio Casal Quinteiro
dedf65a5fd gwin32fsmonitorutils: no need to g_assert when using g_new 2016-03-01 08:40:48 +01:00
Ignacio Casal Quinteiro
922cd8424a gwin32fsmonitorutils: no need to check for NULL when using g_free 2016-03-01 08:37:51 +01:00
Ignacio Casal Quinteiro
007e3c5939 gwin32fsmonitorutils: coding style fixes 2016-03-01 08:37:14 +01:00
Sebastian Geiger
7f60cbb701 gio: fix documentation of GAction 2016-02-29 15:47:32 +01:00
Ignacio Casal Quinteiro
45ccd3f951 gwin32filemonitor: some cleanups
Make the code a bit more consistent and get it into preparation to
merge the fs monitor stuff that uses the private struct directly.
2016-02-28 15:05:18 +01:00
Ignacio Casal Quinteiro
bc5b7332b7 Improve error on win32input/output streams 2016-02-25 17:23:50 +01:00
Ignacio Casal Quinteiro
73192b84f8 gwin32outputstream: cleanups to make the code more consistent 2016-02-25 10:00:32 +01:00
Ignacio Casal Quinteiro
d5cb451c51 gwin32inputstream: some cleanups to make the code more consistent 2016-02-25 09:56:25 +01:00
Ignacio Casal Quinteiro
53a24814f6 gsettingschema: fix uninitialized value warning
This error could actually happen in case the assertions are off.
2016-02-24 17:20:57 +01:00
Ignacio Casal Quinteiro
f3334b47ec Revert "registrybackend: use G_DECLARE_FINAL_TYPE"
This reverts commit b0776ddd18.
mingw does not seem to like this patch so better go on the safe
way.
2016-02-24 09:33:22 +01:00
Ignacio Casal Quinteiro
13057bb73e registrybackend: fix warning about unused variable 2016-02-24 09:18:42 +01:00
Tobias Nygren
0d0db60959 gio/gtestdbus.c: don't use non-standard %m printf modifier
https://bugzilla.gnome.org/show_bug.cgi?id=756706
2016-02-19 11:29:32 +00:00
Lars Uebernickel
b32f8ba19b gapplication: add a way to override the app-id
Some applications support running in a mode where they present
themselves as a different application to the user (for example web
browsers or terminals).

To facilitate this, add an option --gapplication-app-id which allows
users to override an application's id from desktop files or similar.

Applications need to opt-in to this by setting the
G_APPLICATION_CAN_OVERRIDE_APP_ID flag.

https://bugzilla.gnome.org/show_bug.cgi?id=743933
2016-02-18 08:18:58 -05:00
Matthias Clasen
caf03300e5 Remove leftover markup 2016-02-17 20:10:43 -05:00
Cole Robinson
a3a97dca3a gsettings: schema_list should use the passed schema's source
currently schema_list will iterate over the default SchemaSource
list, and not the one associated with the passed in Schema. This
means schema_list can give incorrect results for a Schema fetched
from a non-default SchemaSource, like via new_from_directory.

https://bugzilla.gnome.org/show_bug.cgi?id=757506
2016-02-16 10:57:58 -05:00
Ignacio Casal Quinteiro
19fd89f8db registrybackend: avoid adding a new child when we return the root 2016-02-05 12:05:02 +01:00
Ignacio Casal Quinteiro
63b0f1087d registrybackend: another cleanup creating a registry cache item 2016-02-05 11:39:30 +01:00
Ignacio Casal Quinteiro
c73e9fc36a registrybackend: use registry_cache_add_item instead of creating manually 2016-02-05 11:14:24 +01:00
Ignacio Casal Quinteiro
bd3dd1cd48 registrybackend: get whether a key is writable or not 2016-02-05 10:44:45 +01:00
Руслан Ижбулатов
604ca89176 registrybackend: do convert values to UTF-16
Perform conversion before writing a value out of the cache into the registry,
and convert back when reading a value into the cache out of the registry.
The registry holds UTF-8 strings.
2016-02-05 09:40:30 +01:00
Руслан Ижбулатов
c4d943186e registrybackend: fix memory leak 2016-02-05 09:39:21 +01:00
Ignacio Casal Quinteiro
b8fc289e8f registrybackend: remove useless include 2016-02-04 12:44:11 +01:00
Ignacio Casal Quinteiro
74442a0b8c registrybackend: do not leak self if there are no items 2016-02-04 11:16:45 +01:00
Ignacio Casal Quinteiro
dc97bb9b9b registrybackend: handle readability of the keys
If a key is removed or it cannot be read anymore we should
notify the backend about it so it fallbacks to the default
value.
2016-02-04 11:02:46 +01:00
Ignacio Casal Quinteiro
05dd91a0b6 registrybackend: use unicode calls intead of the ansi ones
https://bugzilla.gnome.org/show_bug.cgi?id=761504
2016-02-04 08:59:59 +01:00
Ignacio Casal Quinteiro
7161d70955 registrybackend: remove useless get_permission override
The base class does the same
2016-02-04 07:55:25 +01:00
Ignacio Casal Quinteiro
259a61ed2d registrybackend: pass the event to the cache update
This way the registry cache has more control to specify what has
changed.
2016-02-03 19:19:50 +01:00
Rico Tzschichholz
e3189527dc gio/gobject: Various introspection fixes 2016-02-03 18:13:49 +01:00
Ignacio Casal Quinteiro
c7ea434e2c registrybackend: properly propagate the partial key name 2016-02-03 13:10:09 +01:00
Ignacio Casal Quinteiro
f1a5e394b0 registrybackend: rename touched flag to readable
This is a flag used to understand if a key exists on the registry
and if it is readable. It makes more sense to rename it as readable
since anyway a key that does not exists anymore is a key that is
not readable.
2016-02-02 14:48:22 +01:00
Ignacio Casal Quinteiro
5cc997f7c4 registrybackend: close the key only if successfully opened 2016-02-02 11:08:50 +01:00
Ignacio Casal Quinteiro
bf3f827ca1 registrybackend: use ptr_array_new_with_free_func 2016-02-02 11:08:42 +01:00
Ignacio Casal Quinteiro
9098a7f927 registrybackend: minor style cleanup 2016-02-02 11:04:56 +01:00
Rico Tzschichholz
d268d9f86a socket: Fix annotation of g_socket_receive_message
https://bugzilla.gnome.org/show_bug.cgi?id=761337
2016-02-02 10:15:04 +01:00
Rico Tzschichholz
ec173eb654 application: Fix annoation of g_application_add_option_group
https://bugzilla.gnome.org/show_bug.cgi?id=761337
2016-02-02 10:11:08 +01:00
Ignacio Casal Quinteiro
169cfb250f registrybackend: avoid signed/unsigned comparison warnings 2016-02-01 14:25:05 +01:00
Ignacio Casal Quinteiro
b0776ddd18 registrybackend: use G_DECLARE_FINAL_TYPE 2016-02-01 14:24:46 +01:00
Sébastien Wilmet
95dd373024 docs: better documentation for g_file_info_copy_into()
The documentation of g_file_info_copy_into() was misleading. The
attributes are not just copied, @dest_info is also cleared at the
beginning. So any previously set attributes in @dest_info are lost.

There was a bug in gedit about this function, where some metadata were
not saved. So it might make sense to change the implementation to not
clear @dest_info, and copy one by one the attributes from @src_info to
@dest_info.

https://bugzilla.gnome.org/show_bug.cgi?id=747927
2016-01-28 20:31:53 +01:00
Sébastien Wilmet
a4ed89bf75 docs: improve doc of g_file_info_list_attributes()
The name_space can be NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=747927
2016-01-28 18:49:28 +01:00
Matthias Clasen
42699e37be gio: Include filename in error message
I'm tired of seeing 'No such file or directory' in the logs without
a hint as to what is actually wrong. Including the filename here
may help me tracking down a bug in the continuous infrastructure.
2016-01-27 21:05:31 -05:00
Chun-wei Fan
d20e88fd11 gwinhttpfile.c: Fix build on Visual Studio
Visual Studio, at least the older versions, cannot use L on macros which
are defined as a constant string, plus the L must be applied to all string
literals here.  This does not look nice, but this is life...
2016-01-26 23:23:42 +08:00
Ignacio Casal Quinteiro
56b0454ba5 registrybackend: fix warning 2016-01-26 15:41:08 +01:00
Ignacio Casal Quinteiro
b57eac68e5 registrybackend: fix double-free error 2016-01-26 15:22:48 +01:00
Ignacio Casal Quinteiro
df1ffe7e27 registrybackend: remove :( from messages 2016-01-26 14:35:31 +01:00
Ignacio Casal Quinteiro
0200e4036c registrybackend: simplify g_message_win32_error 2016-01-26 13:26:41 +01:00
Ignacio Casal Quinteiro
bc85dee6b3 registrybackend: do not accept 0 as a windows error
We might end up removing from the error stack the wrong error
and this might be missleading
2016-01-26 13:19:56 +01:00
Ignacio Casal Quinteiro
bad7e4a114 registrybackend: do not leak the watch data in case of failure 2016-01-26 13:15:51 +01:00
Ignacio Casal Quinteiro
31aab1bd42 registrybackend: do not leak key and event if it cannot add the watch 2016-01-26 12:53:56 +01:00
Ignacio Casal Quinteiro
a92d97ff1f registrybackend: more style fixes
This is the never ending story
2016-01-26 12:21:48 +01:00
Ignacio Casal Quinteiro
1b5b0eff9a registrybackend: fix possible crash if cache_node is NULL 2016-01-26 12:02:18 +01:00
Ignacio Casal Quinteiro
67f6ede3e5 registrybackend: remove space before ++ 2016-01-26 11:46:51 +01:00
Ignacio Casal Quinteiro
8f7aa273de registrybackend: fix possible mem leak
If the parameters do not validate we would leak the memory.
2016-01-26 11:42:33 +01:00
Ignacio Casal Quinteiro
305a9b12c9 winhttpfile: use glib format string macro
Like this we avoid some downstream patching for msys2
2016-01-26 10:13:02 +01:00
Ignacio Casal Quinteiro
a89629db1d registrybackend: use the glib format string macro 2016-01-26 10:10:39 +01:00
Ignacio Casal Quinteiro
a159bc939d registrybackend: more cleanups 2016-01-26 09:00:35 +01:00
Ignacio Casal Quinteiro
7256f2289a registrybackend: more cleanups 2016-01-25 16:12:59 +01:00
Ignacio Casal Quinteiro
a5e819c4c3 registrybackend: style fixes 2016-01-25 16:02:03 +01:00
Philip Withnall
8c263008bb build: Calculate ABS_GLIB_RUNTIME_LIBDIR at build time
Rather than calculating it at configure time. This means it can expand
$libdir properly, and use the Make $(realpath) function rather than
invoking the non-portable `readlink -f`.

This fixes problems where `readlink` would be called on an invalid path
(due to a variable not being expanded) and would evaluate to "", which
would then cause things to be installed in the wrong place.

https://bugzilla.gnome.org/show_bug.cgi?id=744772
2016-01-24 14:44:44 +00:00
Philip Withnall
3c0cddfe80 gdbusobjectmanagerserver: Clarify recommended ObjectManager paths
Otherwise people might try to export the object manager at ‘/’, which
doesn’t work. And I have no intention of making it work.

https://bugzilla.gnome.org/show_bug.cgi?id=760852
2016-01-19 17:10:40 +00:00
Philip Withnall
1725580f26 gdbusobjectmanagerserver: Convert a DocBook link to Markdown 2016-01-19 17:01:14 +00:00
Philip Withnall
c3d6934f18 gio: Add DTLS interfaces
Add a new GDtlsConnection interface, plus derived GDtlsClientConnection
and GDtlsServerConnection interfaces, for implementing Datagram TLS
support in glib-networking.

A GDtlsConnection is a GDatagramBased, so may be used as a normal
datagram socket, wrapping all datagrams from a base GDatagramBased in
DTLS segments.

Test cases are included in the implementation in glib-networking.

https://bugzilla.gnome.org/show_bug.cgi?id=752240
2016-01-18 14:25:06 +00:00
Allison Ryan Lortie
86c5d8978d GDBusMethodInvocation: document behaviour change
We changed the behaviour of this API to adapt to a change in the D-Bus
specification.  Document the new behaviour, along with the time of the
change.

https://bugzilla.gnome.org/show_bug.cgi?id=755421
2016-01-13 10:51:44 -05:00
Lars Uebernickel
dbea81b02d gdbus: don't send unexpected replies
gdbus sets NO_REPLY_EXPECTED when no callback is given to
g_dbus_connection_call(). It makes sense that it also handles the server
side correctly by discarding replies to clients that don't want one.

https://bugzilla.gnome.org/show_bug.cgi?id=755421
2016-01-13 10:44:49 -05:00
Philip Withnall
3add5e2837 gio: Document thread safety of the streams API
Specifically, GIOStream and the TLS connection streams.

Includes wording adapted from suggestions by Dan Winship
<danw@gnome.org>.

https://bugzilla.gnome.org/show_bug.cgi?id=735754
2016-01-11 15:58:42 +00:00
Javier Jardón
4e78a0a9df Revert "Use upstream gettext instead the glib one"
This causes several problems:
- Compilation in FreeBSD with --enable-gtk-doc broke
- Modules that still use the AM_GLIB_GNU_GETTEXT macro
  doesnt compile anymore because /usr/share/glib-2.0/gettext
  is not filled with the correct files, as this was done in
  the glib custom po/Makefile.in.in

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

This reverts commit e5c752371c.
2016-01-10 22:44:24 +00:00
Javier Jardón
e5c752371c Use upstream gettext instead the glib one
https://bugzilla.gnome.org/show_bug.cgi?id=622991
2016-01-09 18:49:22 +00:00
Matt Watson
c1e2a8d727 resource file: add cancel to dummy monitor
gfilemonitor has a cancel vfunc and will call into the in dispose.
If we don't stub it out we get a segfault.
2016-01-08 18:08:20 -08:00
Daiki Ueno
50645b724a gsettings: Install gettext ITS rules
Recent gettext has a feature to allow consumer projects to supply their
own string extraction rules for XML files, in ITS format.

Gettext still ships the rule for *.gschema.xml, but it would be better
maintained in the upstream project.

See the gettext documentation for details:
http://www.gnu.org/software/gettext/manual/html_node/Preparing-ITS-Rules.html

https://bugzilla.gnome.org/show_bug.cgi?id=760199
2016-01-08 12:31:18 +09:00
Christophe Fergeau
ea5ca11761 gio: Document that g_inet_address_new_* return value must be g_object_unref'ed 2016-01-07 15:21:08 +01:00
Steven Chamberlain
42b160b19f gio: drop obsoleted lock causing deadlocks on FreeBSD
I think it is a recursion from the GUnixMountMonitor constructor, to a
GLocalFileMonitor on /etc/fstab, and into GUnixMountMonitor again, now
with a mutex already held, so it deadlocks.
https://bugzilla.gnome.org/page.cgi?id=traceparser/trace.html&trace_id=235354

That mutex in glocalfile.c:g_local_file_find_enclosing_mount() doesn't
seem necessary any more IMHO.  Inside it, only 'mount' is modified, but
that's just a stack variable local to this function.  When
klass->get_mount_for_mount_path is called, it's given one const
parameter and the other is unused, so they're unchanged. 'klass'
doesn't seem it could be modified either inside that function.

It doesn't recurse infinitely, but seems to work correctly and pass the
testsuite after this change.

The FreeBSD project already applied my patch in their ports tree, and
their users seem happy with it.

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=712848#64
and https://bugzilla.gnome.org/show_bug.cgi?id=753378
2015-12-23 09:40:54 -05:00
Chun-wei Fan
bec6a9a300 g_application_run(): Fix on Windows When Using Bindings
As g_win32_get_command_line() calls CommandLineToArgvW() to acquire the
arguments passed into a GApplication program, it actually returns the
whole command line which is used to invoke the program, including the
script interpreter and its flags when a script using GNOME bindings
(e.g. PyGObject and so on) is being invoked.

The issue here is that g_application_run() would most probably have
trouble in the scripts scenario on Windows as it is likely unable to
"recognize" the script interpreter, causing such scripts to fail to run.

Largely based on the patch by Ray Donnelly <mingw.android@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=734095
2015-12-22 17:33:33 +08:00
Ignacio Casal Quinteiro
5f4b92202b win32: fix warnings avoid discarding const qualifier 2015-12-21 12:22:10 +01:00
Xavier Claessens
aa9a33b0da GApplication: Avoid getting the default context repeatidly
This avoids getting a global lock on every main loop iteration.

https://bugzilla.gnome.org/show_bug.cgi?id=759554
2015-12-16 11:44:43 -05:00
Jasper St. Pierre
a379a0ad59 gapplication: Acquire the main context before running
Otherwise, we'll acquire it on every loop iteration, which can leave us
vulnerable to racing another thread for the acquisition of the main
context.

This can break methods like g_main_context_invoke, which try to acquire
a context to figure out if it can invoke the method synchronously or
need to defer to an idle. In these cases, it isn't guaranteed that the
invocation function will be invoked in the default main context,
e.g. the one that GApplication is holding.

This also matches what GMainLoop is doing.

https://bugzilla.gnome.org/show_bug.cgi?id=752983
2015-12-16 09:15:43 -05:00
Руслан Ижбулатов
ce985f13f4 Enable contenttype test on W32, tweak it to pass (mostly)
* On W32 use a real directory (SYSTEMROOT) instead of '/etc/'
* Disable test_symbolic_icon() as it can't be passed (symbolic icons are not
  really supported)

* PowerPoint/Gettext test still fails, presumably because msvcrt qsort() moves
  the entires (both have the same priority)

https://bugzilla.gnome.org/show_bug.cgi?id=735696
2015-12-16 07:47:54 -05:00
Руслан Ижбулатов
b86e46e8e7 xdgmime: Finer handling for cases where mmap() is not available
Allocate an empty cache object, check cache objects for being empty
before using them.
Otherwise the code will re-read cache every 5 seconds, as NULL cache
does not trigger the code that stores mtime, which makes the cache
file appear modified/unloaded permanently.

https://bugzilla.gnome.org/show_bug.cgi?id=735696
2015-12-16 07:47:54 -05:00
Matthias Clasen
04c56cf6e7 gsettings: Don't translate ""
The empty msgid is traditionally used to store po file metadata,
so calling gettext with an empty msgid is not the right thing
to do.

https://bugzilla.gnome.org/show_bug.cgi?id=756214
2015-12-16 07:47:53 -05:00
Allison Ryan Lortie
30359e7409 file monitors: reorder some code to avoid segfault
We must initialise '->source' before we use fields inside of it.

https://bugzilla.gnome.org/show_bug.cgi?id=758823
2015-12-16 07:47:53 -05:00
c2d0c40bff Fix gettext use
gettext() calls inside library have to use gi18n-lib.h.

https://bugzilla.gnome.org/show_bug.cgi?id=758553
2015-12-16 07:47:53 -05:00
Roman Lebedev
4cda92b587 glib-compile-resources: do not leak c_name
As per #578363, "if one requests e.g. strings via GOptionEntry.arg_data
then those are strduped and needs to be free'ed by the application."

Fixes following leak:

=================================================================
==29426==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 10 byte(s) in 1 object(s) allocated from:
    0 0x7f3ab783d37a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9437a)
    1 0x7f3ab70f7c82 in g_malloc /home/lebedevri/src/glib/glib/gmem.c:94
    2 0x7f3ab70f7f60 in g_malloc_n /home/lebedevri/src/glib/glib/gmem.c:330
    3 0x7f3ab713258e in g_strndup /home/lebedevri/src/glib/glib/gstrfuncs.c:425
    4 0x7f3ab709c86b in strdup_len /home/lebedevri/src/glib/glib/gconvert.c:864
    5 0x7f3ab709c966 in g_locale_to_utf8 /home/lebedevri/src/glib/glib/gconvert.c:905
    6 0x7f3ab7103c32 in parse_arg /home/lebedevri/src/glib/glib/goption.c:1276
    7 0x7f3ab71066fb in parse_long_option /home/lebedevri/src/glib/glib/goption.c:1670
    8 0x7f3ab7108047 in g_option_context_parse /home/lebedevri/src/glib/glib/goption.c:1997
    9 0x408532 in main /home/lebedevri/src/glib/gio/glib-compile-resources.c:629
    10 0x7f3ab6c72b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

https://bugzilla.gnome.org/show_bug.cgi?id=757299
2015-12-16 07:47:53 -05:00
Allison Ryan Lortie
21b1c390a3 GApplication: destroy the impl on shutdown
It's theoretically possible (and see in the wild) for D-Bus messages to
come in to the application after shutdown() has been called and while
we're draining out the lingering events in the main context.

Prevent this from happening by ensuring we unregister our objects on
D-Bus during the shutdown process.

https://bugzilla.gnome.org/show_bug.cgi?id=757372
2015-12-16 07:47:53 -05:00
Ryan Lortie
aa16359986 Stop supporting non-POSIX getpwuid_r, getgrgid_r
Bug 13403 introduced support for the non-POSIX variants of these APIs
found on a system called "DG/UX".  Meanwhile, the complicated checks
here are breaking cross-builds on systems that we actually care about.

Remove the complicated checks and replace them with AC_CHECK_FUNCS.
Remove the resulting dead code from a couple of .c files.

https://bugzilla.gnome.org/show_bug.cgi?id=756475
2015-12-16 07:47:53 -05:00
Paolo Borelli
c97729532f W32: fix uninitialized var in g_app_info_get_all_for_type
Compare with the handler->app, not with the app var which is not
initialized yet

https://bugzilla.gnome.org/show_bug.cgi?id=759408
2015-12-14 14:32:17 +01:00
Emmanuele Bassi
a81568273c docs: Be more precise on the use of set_resource_base_path()
The current wording is a bit vague on when to call
set_resource_base_path() in a GApplication implementation.
2015-12-01 12:57:02 +00:00
Matthias Clasen
9787790448 GApplication: improve docs
Spell out which GVariant format strings to use for which
commandline option types. I just wasted some time debugging
this in an application.
2015-11-25 21:38:20 -05:00
Evangelos Foutras
db641e3292 GDBusProxy: Fix a memory leak during initialization
https://bugzilla.gnome.org/show_bug.cgi?id=758641
2015-11-25 17:33:11 -05:00
Ben Iofel
7ab79b3879 GTask: fix example code in docs
https://bugzilla.gnome.org/show_bug.cgi?id=758181
2015-11-16 12:33:02 -05:00
Philip Withnall
25a7c817d3 glib: Add missing (nullable) and (optional) annotations
Add various (nullable) and (optional) annotations which were missing
from a variety of functions. Also port a couple of existing (allow-none)
annotations in the same files to use (nullable) and (optional) as
appropriate instead.

Secondly, add various (not nullable) annotations as needed by the new
default in gobject-introspection of marking gpointers as (nullable). See
https://bugzilla.gnome.org/show_bug.cgi?id=729660.

This includes adding some stub documentation comments for the
assertion macro error functions, which weren’t previously documented.
The new comments are purely to allow for annotations, and hence are
marked as (skip) to prevent the symbols appearing in the GIR file.

https://bugzilla.gnome.org/show_bug.cgi?id=719966
2015-11-07 10:48:32 +01:00
Sebastien Bacher
90808a0279 g_local_file_trash: remove invalid free call
Commit 8ece2de964 transplanted a block of
code that contained an early-exit-on-error case which freed several
variables.

Because of the move, the normal-path unconditional free of one of these
variables is now above this early exit case, so if this block is hit, it
will now be a double-free.

Remove that.

https://bugzilla.gnome.org/show_bug.cgi?id=757693
2015-11-06 11:55:57 -05:00
Philip Withnall
1ac2a606fc gtlsconnection: Fix a typo in the documentation 2015-11-06 11:27:24 +01:00
Jussi Kukkonen
1c6e6671d1 gio/tests: Don't depend on a data file that's not built
data.gresource is not built when cross-compiling: Don't
add it to test_data in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=757628
2015-11-05 13:50:13 +02:00
Simon McVittie
236e8040b4 Build gdbus-example-objectmanager-server again
It was removed, apparently accidentally, in commit 5b48dc4.
This had the side-effect that it wasn't included in tarball releases,
which means that commit ab7b4be doesn't work when building a package.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=734469
Reviewed-by: Colin Walters <walters@verbum.org>
2015-11-02 20:36:42 +00:00
Lars Uebernickel
ee718d3526 gapplication: reject actions without names
https://bugzilla.gnome.org/show_bug.cgi?id=756134
2015-11-02 13:52:10 +01:00
Daiki Ueno
863bffdac7 doc: fix g_task_attach_source() example
The 3rd argument of the function is not a GCallback, but a GSourceFunc.

https://bugzilla.gnome.org/show_bug.cgi?id=757451
2015-11-02 11:14:04 +09:00
Xavier Claessens
df352203d6 Stop using g_sequence_get_length() to check if it's empty
g_sequence_is_empty() is more efficient for that task.

https://bugzilla.gnome.org/show_bug.cgi?id=756988
2015-10-30 11:35:28 -04:00
Xavier Claessens
2331437df3 Doc: fix some gtk-doc warnings
https://bugzilla.gnome.org/show_bug.cgi?id=755364
2015-10-30 10:30:55 -04:00
Matthias Clasen
a036bd38a5 Try to fix the desktop-app-info test
This was broken in 2bb898c60f.
2015-10-26 13:52:47 -04:00
Rico Tzschichholz
e93aaeb533 gio: Fix version of "Since" annotation 2015-10-25 19:43:54 +01:00
Dan Winship
4dae2d8289 gtask: re-fix tasks-blocking-other-tasks
The new "slowly add more task threads" code doesn't fully deal with
apps that queue lots and lots of tasks which then block on tasks from
their task threads. Fix this by bringing back the "task is blocking
other task" check and making sure that such tasks get bumped to the
front of the queue.

https://bugzilla.gnome.org/show_bug.cgi?id=687223
2015-10-24 10:37:22 -04:00
Dan Winship
263aac125e .gitignore updates 2015-10-23 11:28:03 -04:00
Víctor Manuel Jáquez Leal
3bb8294e00 giomodule: return a copy of module name
This is a regression from commit 6dedc0.

The clients expect to free the received module name, so the function
must return a copy.

https://bugzilla.gnome.org/show_bug.cgi?id=756952
2015-10-22 11:21:47 +02:00
Ignacio Casal Quinteiro
144a87a643 Use bin/gio/modules when building with visual studio 2015-10-22 09:22:01 +02:00
Ignacio Casal Quinteiro
6dedc0364a Factor out a get_gio_module_dir
This also fixes some memory leaks on windows
2015-10-22 08:42:22 +02:00
Ignacio Casal Quinteiro
ad0f340c27 win32: let glib to use the right path separator for the modules 2015-10-20 16:13:08 +02:00
Ryan Lortie
8ece2de964 g_local_file_trash: write info file first
Recent changes to file monitors removed the delay before events were
reported.  Among other things, this caused the trash backend of gvfs to
notice trashed files sooner than before.

On noticing trashed files, the backend tries to read the info file to
discover (among other things) the original location of the file.

Unfortunately, g_local_file_trash() does a strange dance when trashing a
file.  It does a loop of open(O_EXCL) in order to file an empty filename
in the trash to write an info file to, trashes the file, and only then
writes the contents of the info file.  This means that at the time the
file is moved to the trash, the info file is an empty stub.

Change the order so that we write out the actual content of the info
file first.  If the actual trash files then we will unlink the info file
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=749314
2015-10-14 18:08:02 +01:00
Philip Withnall
128c413261 gsocketconnectable: Add a to_string() virtual method
Add string serialisation functions for GNetworkAddress, GSocketAddress,
GUnixSocketAddress, GInetSocketAddress, GNetworkService and
GSocketConnectable. These are intended for use in debug output, not for
serialisation in network or disc protocols.

They are implemented as a new virtual method on GSocketConnectable:
g_socket_connectable_to_string().

GInetSocketAddress and GUnixSocketAddress now implement
GSocketConnectable directly to implement to_string(). Previously they
implemented it via their abstract parent class, GSocketAddress.

https://bugzilla.gnome.org/show_bug.cgi?id=737116
2015-10-13 15:42:14 +01:00
Philip Withnall
4e631d2e5f gio: Add GDatagramBased interface and rebase GSocket on it
GDatagramBased is an interface abstracting datagram-based communications
in the style of the Berkeley sockets API. It may be contrasted to (for
example) GIOStream, which supports only streaming I/O.

GDatagramBased allows socket-like communications to be done through any
object, not just a concrete GSocket (which wraps socket()).

This adds the GDatagramBased interface, and implements it in GSocket.

https://bugzilla.gnome.org/show_bug.cgi?id=697907
2015-10-13 15:33:48 +01:00
Mike Frysinger
e5e08ebedb gthreadedresolver.c: Fix for Android 5.0+
https://bugzilla.gnome.org/show_bug.cgi?id=756477
2015-10-13 09:04:39 -04:00
Debarshi Ray
cd1eba043c docs: Improve the text on G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START
... and fix a couple of typos in the process.

https://bugzilla.gnome.org/show_bug.cgi?id=756251
2015-10-09 14:16:29 +02:00
John Hiesey
16e0a5a886 goutputstream: Report input stream read failure correctly
When G_OUTPUT_STREAM_CLOSE_TARGET is set,
g_output_stream_real_splice was not returning -1 in any error
cases, since the success flag was being overwritten.

https://bugzilla.gnome.org/show_bug.cgi?id=756255
2015-10-08 20:07:08 +02:00
Philip Withnall
ac05ad55fa gdbusconnection: Add missing (nullable) to get_peer_credentials()
Since Colin mentioned it on gir-devel-list.
2015-10-06 07:59:19 +01:00
Olivier Fourdan
4919c25d49 GDesktopAppInfo: Do not set the DISPLAY in gio
The environment variable DISPLAY makes sense only for X11, it should
not be set in gio.

Beside, if the backend is not X11 but Wayland, forcing the value of
DISPLAY to the Wayland display will confuse the backend selection and
possibly crash the applications.

https://bugzilla.gnome.org/show_bug.cgi?id=754983
2015-10-05 23:21:43 -04:00
Philip Withnall
212b0c28cc gsocket: Fix g_socket_send_messages_with_timeout() on win32
Commit a0cefc2217 introduced an unresolved
symbol, g_socket_send_message_with_timeout(), on win32. Windows
unfortunately isn’t clever enough to fill in the gaps and magic up the
implementation of that function from nowhere, so we had better do it
ourselves.

Factor the blocking behaviour out of g_socket_send_message() into a new
internal g_socket_send_message_with_timeout().

https://bugzilla.gnome.org/show_bug.cgi?id=756054
2015-10-05 16:15:19 +01:00
Chun-wei Fan
e81d4ea988 gio/goscket.c: Fix build on Windows
5d68947 factored out resuable items, but some of these are only for
*NIX builds, which will break the build on Windows.  Fix this by
building these portions only when !G_OS_WIN32.

https://bugzilla.gnome.org/show_bug.cgi?id=756053
2015-10-05 17:15:12 +08:00
Philip Withnall
9b7f5ad611 gunixsocketaddress: Clarify construction behaviour of anonymous addrs
Clarify the handling of G_UNIX_SOCKET_ADDRESS_ANONYMOUS in the
documentation for g_unix_socket_address_new_with_type().
2015-10-04 15:26:37 +01:00
Philip Withnall
fc59c20e97 gsocket: Minor documentation clarifications
As suggested by Dan Winship on bug #697907.
2015-10-04 11:34:36 +01:00
Philip Withnall
237fec7e70 gsocket: Fix connected state if shutting down in two steps
The value of g_socket_is_connected() gets stuck high if the GSocket is
shut down in two steps:
   g_socket_shutdown (socket, TRUE, FALSE, NULL);
   g_socket_shutdown (socket, FALSE, TRUE, NULL);
rather than one:
   g_socket_shutdown (socket, TRUE, TRUE, NULL);

Fix that by tracking the connected status for the read half and the
write half of the connection separately.

https://bugzilla.gnome.org/show_bug.cgi?id=697907
2015-10-04 10:39:13 +01:00
Philip Withnall
456e02f280 gdbusaddress: Fix memory leak when G_DBUS_DEBUG_ADDRESS is enabled
Coverity CID: 1325374
2015-10-03 11:52:27 +01:00
Philip Withnall
0f98b2f4ec gsocks5proxy: Fix error reporting in authentication
set_auth_msg() was returning FALSE to indicate error, but all its
callers were expecting a negative return value to indicate error. This
was causing memory leaks for the GError, and errors to not be reported.

Coverity CID: 1325357
2015-10-03 11:46:18 +01:00
Philip Withnall
c1c001e300 gresource-tool: Fix minor memory leak when listing resources
Coverity CID: 1325353
2015-10-03 11:43:49 +01:00
Philip Withnall
292fd1155a gtlscertificate: Fix error reporting if a GError is not passed in
If the certificate constructor is called as:
   g_tls_certificate_new_from_pem (data, length, NULL);
and PEM parsing fails for the private key, the function would have
continued to try and create a certificate using a NULL key_pem value,
which would have failed or crashed.

Use g_propagate_error() correctly to avoid this.

Coverity CID: 1325403
2015-10-03 10:58:18 +01:00
Philip Withnall
9275be383f glocalfile: Fix memory leak in find_topdir_for()
Coverity CID 1325398.
2015-10-03 10:48:46 +01:00
Olivier Crête
be732677f5 gio: Add G_IO_ERROR_MESSAGE_TOO_LARGE
Corresponding to EMSGSIZE, for when UDP datagrams are rejected due to
being too big.

https://bugzilla.gnome.org/show_bug.cgi?id=752240
2015-10-01 14:31:40 +01:00
Philip Withnall
1086507e75 gsocket: Fix error behaviour of g_socket_send_messages()
If an error in the underlying sendmmsg() syscall occurs after
successfully sending one or more messages, g_socket_send_messages()
should return the number of messages successfully sent, rather than an
error. This mirrors the documented sendmmsg() behaviour.

This is a slight behaviour change for g_socket_send_messages(), but as
it relaxes the error reporting (reporting errors in fewer situations
than before), it should not cause problems.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 14:10:10 +01:00
Philip Withnall
f62cbfc022 gsocket: Add g_socket_receive_messages()
Add support for receiving multiple messages with a single system call,
using recvmmsg() if available. Otherwise, fall back to looping over
g_socket_receive_message().

This adds new API, g_socket_receive_messages(), and corresponding unit
tests.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 14:10:10 +01:00
Philip Withnall
a0cefc2217 gsocket: Switch internal functions from blocking booleans to timeouts
In order to support per-operation timeouts on new API like
g_socket_receive_messages(), the internal GSocket API should use
timeouts rather than boolean blocking parameters.

   (timeout == 0) === (blocking == FALSE)
   (timeout == -1) === (blocking == TRUE)
   (timeout > 0) === new behaviour

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 13:59:08 +01:00
Philip Withnall
7f985b35ce gsocket: Factor out blocking parameter from g_socket_receive_message()
This will make future API additions easier. The factored version is
internal for the time being.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 13:58:44 +01:00
Philip Withnall
5d68947466 gsocket: Split out functions to convert to and from struct msghdr
As new methods are added to GSocket, we don’t want to duplicate this
code, so factor it out.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 13:58:27 +01:00
Philip Withnall
8c4c16ddf4 giotypes: Add GInputMessage struct
This complements the GOutputMessage struct. It will shortly be used for
adding a g_socket_receive_messages() function, but needs to be committed
first to allow some internal refactoring of GSocket.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-10-01 13:58:07 +01:00
Philip Withnall
ad7250ab53 giostream: Fix a typo in the documentation for g_io_stream_close() 2015-09-30 12:58:08 +01:00
Ryan Lortie
202a9c3497 GLocalFile: return text/plain for empty files
Previously, GLib returned text/plain for empty files.

This is important because people may want to open empty (eg:
just-created) text files with the text editor.

An unintended side-effect of b6fc1df022
caused GLib to start returning application/octet-stream instead of
text/plain for these files.

This commit is essentially a revert of that commit, with a different
solution: we move the special-case up a bit in the function and
hard-code it to text/plain.

This change does not exactly maintain the old behaviour: previously, a
"fast" lookup would have returned application/octet-stream on an empty
file and now it will return text/plain.  I consider this to be an
improvement (since we're returning better data) and don't expect it to
cause problems.

https://bugzilla.gnome.org/show_bug.cgi?id=755795
2015-09-29 12:29:10 -04:00
Philip Withnall
21809c8c0f giostream: Fix some typos in the GIOStream documentation
This doesn’t change the meaning of the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=735754
2015-09-28 13:02:19 +01:00
Philip Withnall
363fa18223 gsocket: Fix documentation for g_socket_send_message()
It is no longer the most fully featured version of this function —
g_socket_send_messages() stole that dubious honour with 2.44.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-09-28 12:47:09 +01:00
Philip Withnall
347e4a75ec gsocket: Clarify GSocket:blocking doesn’t apply to ops with a parameter
Operations which take an explicit blocking parameter are completely
unaffected by GSocket:blocking.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-09-28 12:47:09 +01:00
Philip Withnall
8fdc670188 gsocket: Clarify flags documentation for g_socket_receive_message()
The API design here is a bit awkward — the in/out flags argument should
actually have been an in flags argument and an out msg_flags argument.
Clarify that a bit in the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-09-28 12:47:07 +01:00
Benjamin Gilbert
4745c08220 win32: Fix link error with _wstat32i64() on 64-bit
_wstat32i64() doesn't exist in msvcrt.dll.  This doesn't cause a problem
on 32-bit Windows because mingw-w64 #defines _wstat32i64 to _wstati64,
but on 64-bit Windows we get a link error.

In addition, _wstat32i64() takes a struct _stat32i64 *, but
GLocalFileStat is #defined to struct _stati64, which is not the same
type on 64-bit Windows.

Fix by using _wstati64().

https://bugzilla.gnome.org/show_bug.cgi?id=749161
2015-09-27 16:07:27 -04:00
Matthew Waters
8297ea8bad win32: fix incorrect specifier
error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has
   type ‘gsize {aka long long unsigned int}’ [-Werror=format=]

https://bugzilla.gnome.org/show_bug.cgi?id=755154
2015-09-21 08:37:29 -04:00
Matthias Clasen
2bc094264b Documentation fixups
Various parameter fixups and symbol list additions.
2015-09-21 06:44:58 -04:00
Murray Cumming
846e206146 GListModel docs: It's get_n_items(), not get_length(). 2015-09-16 14:30:29 +02:00
Matthias Clasen
a7b2b5686a Fix make check
I forgot to add the include to make I_() known in gdbusdaemon.c
2015-09-13 13:37:10 -04:00
Matthias Clasen
9acd0ddbf3 gio: Intern all signal names beforehand
This avoids pointless copying of static strings.
2015-09-12 11:13:45 -04:00
Sebastian Dröge
20e8b63477 gioerror: Add more mappings for WinSock error codes
https://bugzilla.gnome.org/show_bug.cgi?id=754560
2015-09-08 17:39:07 +03:00
Chun-wei Fan
041e77249a Cleanup and Enhance the MSVC Project Generation
Make use of the common autotools module that is used to generate the MSVC
project files from their respective templates so that the main build files
beccome cleaner, and enhance them in a way that the headers that should be
installed can be written to the property sheets during 'make dist', so that
the chances of missing headers for MSVC builds can be greatly reduced.

Also use this autotools module to fill in the projects for
glib-compile-schemas and glib-compile-resources.

https://bugzilla.gnome.org/show_bug.cgi?id=735429
2015-09-03 19:10:06 +08:00
Ting-Wei Lan
4a09d0cf7a Fix return value error in g_list_store_sort 2015-09-02 01:19:40 +08:00
Emmanuele Bassi
b04c565f33 gio: Link against gmodule when building tools
Otherwise cross-compilation will fail with linker errors.

https://bugzilla.gnome.org/show_bug.cgi?id=753745
2015-09-01 10:40:24 -04:00
Emmanuele Bassi
5ce70917df Drop binary checks when cross-compiling
We don't need to run binaries we just built in order to successfully
build GLib and friends any more.

Since commit b74e2a7, we don't need to run glib-genmarshal when building
GIO; since commit f9eb9eed, all our tests (including the ones that do
need to run binaries we just built) are only built when running "make
check", instead of unconditionally at every build.

This means that we don't need to check for existing, native binaries
when cross-compiling, and fail the configuration step if they are not
found — which also means that you don't need to natively build GLib for
your toolchain, in order to cross-compile GLib.

We can also use the cross-compilation conditional, and skip those tests
that require a binary we just built in order to build.

https://bugzilla.gnome.org/show_bug.cgi?id=753745
2015-09-01 10:40:24 -04:00
Matthias Clasen
1dec512a66 Revert "GSettings: delay backend subscription"
This reverts commit 8ff5668a45.

This change has had considerable fallout, and there was no
follow-up to address it.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2015-09-01 10:21:26 -04:00
Matthias Clasen
7fff264777 Revert "GSettings: fix check for delaying backend subscription"
This reverts commit d511d6b37f.
2015-09-01 10:18:23 -04:00
Dan Winship
9f2e3f6b72 gtestutils: add g_assert_cmpmem()
Add a test macro to compare two buffers (which are not already known
to be the same length) for equality.

https://bugzilla.gnome.org/show_bug.cgi?id=754283
2015-08-31 13:59:48 -04:00
Matthias Clasen
34ec21fab5 win32: Fix a g_once_init_enter call
g_once_init_enter must be given a gsize-sized location.
A gboolean doesn't qualify. This broke the build on win64.

http://bugzilla.gnome.org/show_bug.cgi?id=754307
2015-08-31 13:48:22 -04:00
Matthias Clasen
591eabcbbc Remove an unused variable 2015-08-31 13:43:47 -04:00
Matthias Clasen
e5734c37a6 Add g_list_store_sort
GListStore already has a g_list_store_insert_sorted function,
which can be used to keep the list sorted according to a fixed
sort function. But if the sort function changes (as e.g. with
sort columns in a list UI), the entire list needs to be
resorted. In that case, you want g_list_store_sort().

https://bugzilla.gnome.org/show_bug.cgi?id=754152
2015-08-31 10:40:45 -04:00
Michael Catanzaro
516adb99c0 Add certificate chain construction test
Enhance GTestTlsBackend to allow setting the issuer property of
GTlsCertificates, and add a test to ensure certificate chain
construction with g_tls_certificate_new_from_pem() works as expected.

https://bugzilla.gnome.org/show_bug.cgi?id=754264
2015-08-29 08:43:29 -05:00
Michael Catanzaro
587068c969 GTlsCertificate: fix loading of chain with private key
If a private key (or anything, in fact) follows the final certificate in
the file, certificate parsing will be aborted and only the first
certificate in the chain will be returned, with the private key not set.
Be tolerant of this, rather than expecting the final character in the
file to be the newline following the last certificate.

https://bugzilla.gnome.org/show_bug.cgi?id=754264
2015-08-29 08:43:29 -05:00
Dan Winship
1ab3e3ed3e gsocket: add a wrapper around g_set_error() to avoid extra work
If @error is NULL then we don't even need to evaluate the remaining
arguments. And if errno is EWOULDBLOCK, then no one should see the
error message anyway, so don't bother g_strdup_printf'ing up a pretty
one.

https://bugzilla.gnome.org/show_bug.cgi?id=752769
2015-08-29 08:46:25 -04:00
K. Adam Christensen
f8341badb8 gfileenumerator: Don't leak memory if out_info is NULL
In the unusual case where one just wants the filenames, avoid
a leak.

https://bugzilla.gnome.org/show_bug.cgi?id=754211
2015-08-28 08:17:24 -04:00
Dan Winship
7da3922d05 gdbus: fix race condition in connection filter freeing
If you called g_dbus_connection_remove_filter() on a filter while it
was running (or about to be run) in another thread, its GDestroyNotify
would be run immediately, potentially causing the filter thread to
crash.

Fix this by refcounting the filters, and using the existing mechanism
for running a GDestroyNotify in another thread in the case where the
the gdbus thread is the one that frees it.

Also, add a bit of documentation explaining this (and add a related
clarification to g_dbus_connection_signal_subscribe()).

https://bugzilla.gnome.org/show_bug.cgi?id=704568
2015-08-24 16:30:05 -04:00
Philip Withnall
76c1f78cb9 gfile: Clarify g_file_get_parent() documentation
Clarify that a parent in this case has to be an immediate parent, not an
arbitrary ancestor several levels up in the tree.
2015-08-24 10:38:27 +01:00
Philip Withnall
50a65cc38a gfile: Clarify g_file_get_path() documentation
Clarify that the returned path (if non-NULL) is guaranteed to be
absolute and canonical, but might still contain symlinks.
2015-08-24 10:37:51 +01:00
Kalev Lember
02f9e84709 gdbus: Add a missing include
This fixes the build on non-unix platforms, such as win32 where
gunixfdlist.h is not included.
2015-08-22 23:13:33 +02:00
Ryan Lortie
b6fc1df022 GLocalFileInfo: don't content-sniff zero-length files
This will prevent attempting to read from some files that appear normal but are
really device-like, such as those in /proc and /sys.

If we can't stat() the file then don't bother attempting to sniff, either.

https://bugzilla.gnome.org/show_bug.cgi?id=708525
2015-08-21 01:00:49 -04:00
Ting-Wei Lan
8f662e7259 glocalfileinfo: Support file creation time on FreeBSD and NetBSD
FreeBSD and NetBSD have field st_birthtim and st_birthtime in struct stat,
respectively, which can be used to get file creation time on supported file
systems such as UFS2 and tmpfs.

https://bugzilla.gnome.org/show_bug.cgi?id=749492
2015-08-21 00:52:50 -04:00
Christophe Fergeau
60a6ae6f0b Fix GError leak in g_file_query_writable_namespaces()
gvfs commit b358ca "Make sure metadata is always returned by
query_writable_namespaces()" changed the
query_writable_namespaces vfunc to never return NULL, but the error
checking in g_daemon_file_query_writable_namespaces still assumes vfunc
failure implies NULL return value and GError set. This causes a memory
leak as on failure the GError will be set but the vfunc implementation
will have created its own default list so NULL will not be returned, and
the GError will never be cleared.

This commit directly checks if the GError is set to detect failures,
my_error is directly dereferenced in the error block anyway.

This also removes an unneeded call to g_file_attribute_info_new(); as
the vfunc always returns us a non-NULL GFileAttributeInfoList.

https://bugzilla.gnome.org/show_bug.cgi?id=747364
2015-08-21 00:45:00 -04:00
Matthias Clasen
fa17536598 Code cleanup 2015-08-21 00:43:54 -04:00
Matthias Clasen
b67dac56e3 Add a test for cross dir moves
This is a test that is described in

https://bugzilla.gnome.org/show_bug.cgi?id=742849
2015-08-21 00:41:09 -04:00
Matthias Clasen
3498f29b81 Test resource filesystem attributes 2015-08-21 00:08:57 -04:00
Matthias Clasen
d942c64267 resource file: Return some filesystem info
We now return "resource" as the filesystem type, and state
that the filesystem if readonly.
2015-08-21 00:01:12 -04:00
Matthias Clasen
1bfdcc8499 resource file: Add a dummy file monitor
This avoids the fallback to polling in GFile, which is unnecessarily
expensive for a resource which can never change.
2015-08-20 23:48:51 -04:00
Matthias Clasen
b995c08bf3 Remove unused files
We no longer have GLocalDirectoryMonitor implementations.
These files were not included in the build for a while now.
2015-08-20 22:31:41 -04:00
Matthias Clasen
d66e3f57cd Add more directory monitoring tests
These tests clear up a misunderstanding of mine: Monitoring
nonexisting files and directories *does* work with the inotify
implementation, it just has a very long timeout for scanning
for missing locations, so the test needs to take that into
account.
2015-08-20 22:30:19 -04:00
Matthias Clasen
ee31d492d8 poll file monitor: Don't reimplement g_strcmp0
We have that function now, so use it.
2015-08-20 21:10:49 -04:00
Debarshi Ray
fa0f51ddf8 fileinfo: Add a G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE attribute
This is meant for opaque, non-POSIX-like backends to indicate that the
URI is not persistent. Applications should look at
G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET for the persistent URI.
Examples of such backends could be a portal for letting sandboxed
applications access the file-system, or a database-backed storage like
Google Drive.

In these cases, the user visible file and folder names are different
from the real identifiers, used by the backend. So, a request to
create google-drive://user@gmail.com/foo/New\ File, would actually
lead to google-drive://user@gmail.com/foo/bar on the server even though
the user visible name is still "New File". Since the server-defined URI
is persistent and sanity-checked by the backend, it is recommended that
applications switch to it as soon as possible. Backends will try to
keep a mapping from "fake" to "real" URIs, but those are only on a
best effort basis. They might not be persistent or have the same
guarantees as the "real" URIs.

https://bugzilla.gnome.org/show_bug.cgi?id=741602
2015-08-20 18:40:02 +02:00
Matthias Clasen
4a076032cf More file monitor tests
Test regular writes and attribute changes with a file monitor,
as well as various file changes under a directory monitor.
2015-08-19 20:33:46 -04:00
Dan Winship
8d8a1c205b fix previous 2015-08-19 16:21:46 -04:00
Dan Winship
c686245141 gdbus: don't warn when returning a value on a closed connection
g_dbus_method_invocation_return_value(), etc, don't have GError
parameters (which makes sense since they won't usually return errors,
and there's not much you could do if they did), so in the rare case
when something does go wrong, they print a warning.

However, there is at least one situation where the warning is a bad
idea: if you are using private bus connections, and a client connects,
makes a request, and then disconnects before getting the response.
Given that there's nothing the caller can do to prevent this case from
getting hit (since the client might not disconnect until after the
call to g_dbus_method_invocation_return_value() starts) and given that
the server can never actually know for sure that the client has
received the response (it might disconnect after reading the response,
but before processing it), just kill the warning in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=753839
2015-08-19 16:08:48 -04:00
Dan Winship
656494a784 gpermission: fix async error returns
a8eedd00 broke the error return values from
g_permission_acquire/release_async() on GSimplePermission. Fix that.
2015-08-19 15:45:11 -04:00
Matthias Clasen
8c32f7c448 Add some file monitoring tests
Add a new test which checks that atomically replacing a file that
is being monitored by GFileMonitor produced the expected events.

The test can easily be expanded to cover other file monitoring
scenarios.
2015-08-19 14:57:53 -04:00
Matthias Clasen
ac78d14125 inotify: Fix handling of paired events for atomic replace
After the big file monitoring rewrite, we only put the IN_MOVED_FROM event
in the queue for such pairs. It matches INOTIFY_DIR_MASK and thus we call
ip_dispatch_event on it, but that function was filtering it out because
the filename in the 'from' event is the one of the temp file, not the
one we are monitoring. That name is in the 'to' event, so compare it as
well, and let the event passin that case.

There is another instance of this check in glocalfilemonitor.c, which is
corrected here as well.

https://bugzilla.gnome.org/show_bug.cgi?id=751358
2015-08-19 14:57:53 -04:00
Janusz Lewandowski
5d014a802a Add a g_dbus_connection_register_object_with_closures function
This is a binding-friendly version of g_dbus_connection_register_object.
Based on a patch by Martin Pitt and the code of g_bus_watch_name_with_closures.

https://bugzilla.gnome.org/show_bug.cgi?id=656325
2015-08-18 16:41:12 -04:00
Felix Riemann
34277d6996 gio: g_menu_item_set_icon should not fail if icon is NULL
It allows passing a NULL icon to unset the icon and thus should not
log a critical warning if used like that.

https://bugzilla.gnome.org/show_bug.cgi?id=753285
2015-08-10 19:00:24 +02:00
Dan Winship
a8eedd00a7 gio: fix a leftover GSimpleAsyncResult usage
And remove remaining unnecessary gsimpleasyncresult.h includes
2015-08-07 09:50:16 -04:00
Dan Winship
e02fa68068 gsettings-tool: fix deprecated call 2015-08-07 09:50:13 -04:00
Dan Winship
ff3dee4bf6 gdbus: fix gdbus-exit-on-close for gdbusconnection change 2015-08-07 09:49:57 -04:00
Colin Walters
66bc9660c4 gdbusconnection: Don't g_printerr() when exiting
exit-on-close for a DBus connection is a completely normal thing.  On
a regular GNOME login, gdm retains the X server, but terminates the
session login bus and associated helpers like gnome-settings-dameon,
the a11y tools, etc.

I've seen several downstream reports of confusion as to what these
apparent error messages mean in the system log.  It doesn't help
that they're so obtuse.

We're also printing them to stderr, when this is not an error.

The reason this was introduced is presumably some people were confused
as to why their process exited when the system bus did.  But the
solution for that I believe is documentation, not printing stuff to
everyone's system log in normal operation.

https://bugzilla.gnome.org/show_bug.cgi?id=742386
2015-08-06 08:51:02 -04:00
Matthias Clasen
905e916573 Don't leak an error
The previous commit introduced a possible memory leak in cases
where we get a G_IO_ERROR_CLOSED error. Make sure to always
free an error, if we got one.

https://bugzilla.gnome.org/show_bug.cgi?id=753278
2015-08-05 17:18:48 -04:00
Stef Walter
b3fcb1442e gdbus: Don't use g_assert_no_error() GDBusObjectManagerServer
There are real world cases where emitting signals can fail, such
as if the DBus connection closes. Asserting and aborting the process
in these cases is just plain lazy.

Ignore the errors when the connection is closed, and turn the
others into warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=753278
2015-08-05 13:43:08 +02:00
Philip Withnall
6b652b1a2e gio: Fix application of GNetworkMonitor:network-metered patch
The wrong patch from https://bugzilla.gnome.org/show_bug.cgi?id=750282
was applied, causing test failures due to not implementing the property
on GNetworkMonitorBase (plus some other omissions).

Fix that by reverting commit a80e7db1a8
and re-applying the correct patch over the top.

https://bugzilla.gnome.org/show_bug.cgi?id=750282
2015-07-29 11:58:02 +01:00
Philip Withnall
7f195ac956 gresource: Clarify error docs for g_resource_enumerate_children()
Document that it returns G_RESOURCE_ERROR_NOT_FOUND if the path doesn’t
exist.
2015-07-28 10:14:17 +01:00
Richard Hughes
a80e7db1a8 gio: Add network metered information to GNetworkMonitor
Add a property to GNetworkMonitor indicating if the network
is metered, e.g. subject to limitations set by service providers.

The default value is FALSE

https://bugzilla.gnome.org/show_bug.cgi?id=750282
2015-07-27 06:44:52 -04:00
Matthias Clasen
c885d42751 Add tests for GApplication::handle-local-options 2015-07-26 21:41:08 -04:00
Christophe Fergeau
243d740c04 gapplication: Stop handle-local-options emission on errors
A signal accumulator can return TRUE to continue signal emission, and
FALSE to stop signal emission. handle-local-options callbacks can return
« return a non-negative option if you have handled your options and
want to exit the process ».

Currently, g_application_handle_local_options_accumulator (the
accumulator for the handle-local-options signal) returns TRUE on
non-negative return value (ie continue signal emission), and returns
FALSE on negative return values (ie when the default option processing
should continue).
This return value seems backward as on >= 0 values, subsequent
handle-local-options callbacks could overwrite the 'exit request' from
the handler, while on < 0 values, the handle-local-options processing
could end up early if several callbacks are listening for this signal.
In particular, the default handler for this signal
(g_application_real_handle_local_options) always returns -1 and will
overwrite >= 0 return values from other handlers.

This commit inverts the check so that signal emission stops early when
one of the handle-local-options callbacks indicates it wants processing
to stop and the process to exit.

https://bugzilla.gnome.org/show_bug.cgi?id=751598
2015-07-26 21:41:08 -04:00
Christophe Fergeau
2551685cf6 gapplication: Fix typos in handle-local-options API doc
The @options parameter was missing an 's', and the name of
g_application_command_line_get_options_dict() was not correct.

https://bugzilla.gnome.org/show_bug.cgi?id=751598
2015-07-26 21:41:08 -04:00
Philip Withnall
8520ae3ffa gsocket: Factor out blocking parameter from g_socket_send_messages()
This will make future API additions easier. The factored version is
internal for the time being.

https://bugzilla.gnome.org/show_bug.cgi?id=751924
2015-07-23 11:37:18 +01:00
TingPing
3cc349b04e win32: Replace usage of __wgetmainargs()
It was an internal function that has been removed with VS 2015

Use g_win32_get_command_line() or CommandLineToArgvW() directly.

https://bugzilla.gnome.org/show_bug.cgi?id=741822
2015-07-23 04:22:59 -04:00
Arun Raghavan
be7de8a7fd gdbusconnection: Fix signal subscription documentation
https://bugzilla.gnome.org/show_bug.cgi?id=752656
2015-07-21 15:20:23 -04:00
Dan Winship
de1bd45fe9 gio/tests/task: fix for change to cancellation behavior
Multiple tasks cancelled at the same time now complete in the opposite
order from how they used to. Fix the test to not assume any particular
order.
2015-07-20 17:35:43 -04:00
Paolo Borelli
45e99833e3 Move a unit test to the right file
Move a test for threaded socket service to socket-service.c.
2015-07-20 00:00:42 +02:00
Paolo Borelli
e1d44799c0 socketservice: add an "active" property
We already have start, stop and is_active methods, but turning it
into a real property is useful for a few reasons:
 - it allows us to bind the property to an UI or a setting
 - it allows us to get notified when the state changes
 - it allows us to instantiate objects directly in the stopped state

https://bugzilla.gnome.org/show_bug.cgi?id=752089
2015-07-20 00:00:02 +02:00
Paolo Borelli
a223796d0b networkaddress: use free_full
https://bugzilla.gnome.org/show_bug.cgi?id=752293
2015-07-19 23:53:35 +02:00
Matthias Clasen
0c12177514 notification: Add an assertion to clarify
Coverity doesn't see that g_enum_get_value will never return
NULL here since we always pass it a valid enum value. Help
it along with an assertion.
2015-07-17 16:46:26 -04:00
Xavier Claessens
dafc454e70 GAsyncInitable: Fix leaked object when using _newv_async 2015-07-08 14:38:16 -04:00
Ryan Lortie
7ed76a4eca file monitors: report MOVED only with both sides
Make sure we know the destination file before reporting a MOVED event.
Otherwise, we should just fall back to reporting it as a DELETED.

https://bugzilla.gnome.org/show_bug.cgi?id=751731
2015-07-06 10:22:36 -04:00
Руслан Ижбулатов
e337fe3163 W32: Add back the dummy g_app_info_reset_type_associations() 2015-07-02 11:06:17 +00:00
Руслан Ижбулатов
155a688635 W32: Add a g_app_info_get_all_for_type() implementation
Also add g_app_info_get_fallback_for_type() and
g_app_info_get_recommended_for_type() as proxies for
g_app_info_get_all_for_type(), until gcontenttype support is improved.
2015-07-02 11:03:47 +00:00
Руслан Ижбулатов
b9d919bd8f Don't ref a NULL pointer 2015-07-02 11:03:47 +00:00
Stef Walter
f405f42115 gsocket: Don't g_error() if file-descriptor is not a socket
This code was out of date with current coding practices.

Nowadays it's common to receive file descriptors over environment
variables from other processes like systemd. The unit files that
control these file descriptors are configurable by sysadmins.

It is not (necessarily) a programmer error when g_socket_details_from_fd()
is called with a file descriptor that is not a socket. It can also
be a system and/or configuration error.

https://bugzilla.gnome.org/show_bug.cgi?id=746339
2015-07-02 12:24:11 +02:00
Iain Lane
f2c1cfe8c7 gio/tests/appmonitor: Delete file before checking for changed event
In 4e7d22e268, deleting the file was moved
after the assertion which checks for the changed event that results from
it being deleted. This is the wrong way around and makes the assertion
fail.

Move the deletion back up before we check the condition. delete_app is
no longer an idle callback so it can be made void. The change
notification might come in when the loop isn't running now, so don't try
to quit if it isn't running. In this case we'll wait for the three
second timeout and the test will still pass.

https://bugzilla.gnome.org/show_bug.cgi?id=751737
2015-07-01 12:11:23 +02:00
Dan Winship
b25fa8feed gio/tests/socket.c: fix on OS X
The semantics of calling shutdown() on a dup()ed socket aren't
well-specified, so don't require any specific behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=747676
2015-06-29 14:40:56 -04:00
Dan Winship
b97d666b2f gio/tests/socket.c: clean up a test case a bit 2015-06-29 14:40:56 -04:00
Matthias Clasen
368c3f205f GTask: Remove unused function
We no longer resort the queue, so this function can go.

https://bugzilla.gnome.org/show_bug.cgi?id=751160
2015-06-29 08:20:26 -07:00
Matthias Clasen
e419e1c4e2 GTask: Avoid resorting
When a task is cancelled, we want to move it to the front
of the queue - our sort function does that for us, but there
is no need to resort the entire queue here, we can just
move the one item and be done with it. This uses just-introduced
threadpool api for this purpose.

https://bugzilla.gnome.org/show_bug.cgi?id=751160
2015-06-29 08:20:26 -07:00
Dan Winship
f9af40a133 Fix a FIXME in the WinXP inet_pton() implementation
https://bugzilla.gnome.org/show_bug.cgi?id=749912
2015-06-29 10:47:35 -04:00
Wouter Paesen
a4c3ab58cc Fix g_inet_address_to_string() on XP
[This patch originally also included an equivalent to the fix that was
committed in 3e29dada, but that was not the complete fix for the bug.]

https://bugzilla.gnome.org/show_bug.cgi?id=749911
2015-06-29 10:46:21 -04:00
Kalev Lember
c612fcab0f gapplication: Initialize backend before withdrawing notifications
Make sure to initialize the notification backend in
g_application_withdraw_notification() the same way as is done in
g_application_send_notification().

This makes it possible for an app to withdraw notifications it has sent
in a previous execution of the application.

https://bugzilla.gnome.org/show_bug.cgi?id=750625
2015-06-23 14:22:41 +02:00
Matthias Clasen
4e7d22e268 Fix distcheck
The appmonitor test was sometimes leaving files behind, causing
distcheck some heartburn.
2015-06-23 06:56:26 -04:00
Chun-wei Fan
3e29dadae4 gio/ginetaddress.c: Fix Windows XP inet_pton() Emulation
We need to be more careful when we try to assign values to gpointers, so
that means we have to assign the value to the properly-dereference
gpointer, so that the assigned value will be retained after the function
returns.  This code will be dropped soon, but it is done for XP
compatibility's sake for 2.44.

Should fix the issue reported in bug 730352 comment #24.
2015-06-23 13:52:25 +08:00
Tim-Philipp Müller
fd789f1187 gsocket: avoid unnecessary select in _send_messages() and _receive_message()
For performance reasons we should always try to send or
receive our messages first and only wait for more space
or data to become available if we get an EAGAIN (and
are in blocking mode).

https://bugzilla.gnome.org/show_bug.cgi?id=751122
2015-06-21 10:28:14 +01:00
Paolo Borelli
9e85f60ec6 socketclient: annotate the connection param of "event" as nullable
When emitting the RESOLVING/RESOLVED events the connection param is
set to NULL.
2015-06-18 16:33:31 +02:00
Philip Withnall
4b02bfd6ee gfile: Clarify that g_file_replace_contents() uses atomic renames
It uses g_file_replace() internally, so is inherently safe.

Though it might vomit .goutputstream-XXXXXX files all over the place
occasionally.
2015-06-17 09:25:49 +01:00
Cosimo Cecchi
0d6e200384 gresource: fix a couple of typos in documentation 2015-06-11 15:56:25 -07:00
Matthias Clasen
1102e6f9ca Allow property actions to invert booleans
This can be handy when you want to change the sense of a toggle
in the UI without rewriting the underlying logic. Currently, this
is just exposed as a construct-only property. We may add a
convenience wrapper or a special !property syntax for this later.

https://bugzilla.gnome.org/show_bug.cgi?id=728489
2015-06-10 21:59:28 -04:00
Matthias Clasen
fb1e5ff04b Fix deprecation notice
GSimpleAsyncResult has not been deprecated all that long.
2015-06-09 19:18:49 -04:00
Simon McVittie
b701c3c608 Regression test for falling back to autolaunch: and XDG_RUNTIME_DIR/bus
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=747941
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-06-09 18:17:25 +01:00
Simon McVittie
32492c6ab0 GDBus: try XDG_RUNTIME_DIR/bus before resorting to dbus-launch
This is the right thing to do for the "a session is a user-session"
model implemented in dbus 1.9.14, which is described in
<http://lists.freedesktop.org/archives/dbus/2015-January/016522.html>.

It also resembles sd-bus' behaviour, although sd-bus will only try
kdbus and XDG_RUNTIME_DIR/bus, and never runs dbus-launch.

On systems following the more traditional "a session is a login-session"
model, X_R_D/bus won't exist, so it is harmless to check for it before
falling back to X11 autolaunching. Again, this matches the behaviour
of current libdbus and sd-bus versions.

Now that we do this, g_test_dbus_unset() needs to clear XDG_RUNTIME_DIR
as well as everything else.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=747941
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-06-09 18:17:16 +01:00
Simon McVittie
0d3f56e31c g_dbus_address_connect: specifically use dbus-launch for autolaunch:
This only alters what happens if we specifically connect to
"autolaunch:", for instance via "DBUS_SESSION_BUS_ADDRESS=autolaunch:".
We will still potentially try other platform-specific things if
DBUS_SESSION_BUS_ADDRESS is unset. There are currently no other
platform-specific things, so there is no practical difference yet,
but I'm about to add a more-preferred fallback path before autolaunch.

This matches libdbus' behaviour and the D-Bus Specification, in which
the autolaunch: transport specifically means X11 autolaunch
(as implemented by "dbus-launch --autolaunch") on Unix, or a
shared-memory-based protocol on Windows. Other platform-specific
transports or default/fallback modes, including launchd on Mac OS X
and XDG_RUNTIME_DIR/bus on Unix, are not part of "autolaunch:".

It's rather unfortunate that the same name means two different
platform-specific mechanisms, specific to different platforms -
if they were added today I'd call them x11: and windows-shm: or
something - but it's been like this since 2007 so it's too late now.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=747941
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-06-09 18:17:01 +01:00
Christophe Fergeau
f45ceb838d gapplication: Make sure --help output is translated
Currently, applications using g_application_add_main_option_entries()
won't get translated entries in --help output. We need to call
g_option_group_set_translation_domain() with a NULL domain to ensure that the
default application gettext domain (ie the one passed to the
textdomain() call) will be used for the main entries passed by the
application.

If we want to allow more flexibility on which gettext domain should be
used for these entries, new API will be needed.

https://bugzilla.gnome.org/show_bug.cgi?id=750322
2015-06-09 13:47:41 +02:00
Philip Withnall
6cd1f8b40f gsettings: Document GSettings build system integration
Add a new section to the main GSettings documentation which documents
the best practices for integrating GSettings into an autoconf/automake
build system using the GLIB_GSETTINGS macro.

Some of this material was adapted from the migrating-gconf.xml guide.

https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-09 08:28:00 +01:00
Philip Withnall
723961b749 gsettings: Expand documentation default value l10n
Mention context, translation category, and the need for syntactic
validity of the translated values.

https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-09 08:28:00 +01:00
Xavier Claessens
73a71d6a43 doc: Add missing GTlsDatabaseClass
https://bugzilla.gnome.org/show_bug.cgi?id=750573
2015-06-08 16:04:53 -04:00
Руслан Ижбулатов
e5e6c25c88 Bump W32 Registry API 'Since:' version
https://bugzilla.gnome.org/show_bug.cgi?id=734888
2015-06-05 18:05:09 -04:00
Руслан Ижбулатов
6579c87bd2 Make W32 registry API compatible with MSVC
* Only check __OBJECT_ATTRIBUTES_DEFINED and __UNICODE_STRING_DEFINED
  on MinGW (MSVC doesn't have these)
* MSVC: disable:4005 when including windows.h and ntstatus.h
* Move NTAPI cconv into the parens with the NtQueryKeyFunc
* Fix return values in some functions

https://bugzilla.gnome.org/show_bug.cgi?id=734888
2015-06-05 18:01:43 -04:00
Руслан Ижбулатов
1ac5b92c2f Add W32 Registry reading API to gio
https://bugzilla.gnome.org/show_bug.cgi?id=734888
2015-06-05 18:01:43 -04:00
Руслан Ижбулатов
2a71f187d7 Make GWin32AppInfo MSVC-compatible - use G_VA_COPY
https://bugzilla.gnome.org/show_bug.cgi?id=666831
2015-06-05 16:17:33 -04:00
Руслан Ижбулатов
4d800e4d86 GWin32AppInfo rewrite
- On first call scan the registry, collect information about URI protocols,
  file extensions, applications and handlers, store that as a set of
  interconnected structures in several hash tables
- Watch the registry keys, re-scan the registry when any one of them changes.

https://bugzilla.gnome.org/show_bug.cgi?id=666831
2015-06-05 16:17:33 -04:00
Ryan Lortie
cb7020af5e GSettings: deprecate g_settings_list_keys()
This is now possible with g_settings_schema_list_keys().

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:26:34 -04:00
Ryan Lortie
6cf867fb2a gsettings tests: use g_settings_schema_list_keys()
Stop using g_settings_list_keys() because soon it will be deprecated.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:24:02 -04:00
Ryan Lortie
bb8eea6148 gsettings tool: use schema for listing keys
Use the newly added g_settings_schema_list_keys() API instead of
g_settings_list_keys() in order to list keys.

Doing this allows the 'list-keys' command to work without creating a
GSettings object, which is more efficient.  It also means that we don't
have to provide a (meaningless and ignored) path when listing keys on
relocatable schemas.

While we're at it, update the 'range' command not to require creation of
a GSettings object, in a similar way.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:24:02 -04:00
Ryan Lortie
82fcfeb3b0 GSettingsSchema: add g_settings_schema_list_keys()
The list of keys in a GSettings object depends entirely on the schema,
so it makes sense to expose this API there.

Move the implementation out of gsettings.c and into gsettingsschema.c,
replacing the earlier with a simple call to the new location.

We don't do the same for children because the children can change.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
2015-06-05 15:24:02 -04:00
Patrick Griffis
36e093a31a Implement GNotification on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=747146
2015-06-05 14:55:58 -04:00
Ryan Lortie
9e8f4d4736 kqueue: add a bit of extra paranoia on cancel
Cancellation of GPollFileMonitor is now handled correctly (in the sense
that no further signals will follow) but let's be extra paranoid and
disconnect our handler anyway, for good measure.

https://bugzilla.gnome.org/show_bug.cgi?id=739424
2015-06-05 14:55:01 -04:00
Ryan Lortie
a367921d44 gpollfilemonitor: send 'changes done' for creates
The new rules of GFileMonitor says that users should expect to see a
CHANGES_DONE_HINT following a CREATED as well as CHANGED.

https://bugzilla.gnome.org/show_bug.cgi?id=739424
2015-06-05 14:55:01 -04:00
Ryan Lortie
62e5ee5514 gpollfilemonitor: don't emit after cancellation
GPollFileMonitor emits CHANGES_DONE_HINT after CHANGED signals, but it
doesn't check to ensure that the file monitor wasn't cancelled before it
does that.

If the original signal caused the monitor to be unreffed, cancelled and
destroyed, we would still end up emitting an extra signal on it.

Avoid that by checking first for cancellation.

https://bugzilla.gnome.org/show_bug.cgi?id=739424
2015-06-05 14:55:01 -04:00
Mikhail Zabaluev
16190d2dcd glib/genviron.c, GSubprocessLauncher: ain't no "filename encoding"
Removed all mentions of GLib file name encoding referring to
the environment strings. The env var content has no defined relation
to GLib's notion of filename encoding, or any encoding whatsoever.
It would be wrong to pass all UTF-8 strings through
g_filename_from_utf8() in order to put them into the environment,
for one thing.

https://bugzilla.gnome.org/show_bug.cgi?id=738185
2015-06-05 14:53:34 -04:00
Jan Safranek
b31a873fb3 GDBus: Add new call flag to allow interactive authorization
DBus has recently introduced new message flag
DBUS_HEADER_FLAG_ALLOW_INTERACTIVE_AUTHORIZATION, which tells that
caller is willing to wait for unspecified amount of time for the call
to return, as the service may perform interactive authorization (e.g.
using polkit).

https://bugzilla.gnome.org/show_bug.cgi?id=739616
2015-06-05 14:35:34 -04:00
Ryan Lortie
865ce79ce0 GActionGroupExporter: flush queue on requests
In order to maintain a logical stream of events, we need to make sure we
flush and queued change notifications before responding to any requests
for information from clients.

If we don't do this, it's possible that we emit an 'add' event that was
queued at the time of a 'DescribeAll' call _after_ the reply to that
call (which already contained the description of the new action).

In practice, this is not only logically incorrect, but it can also cause
problems.  If a change to action 'state' or 'enabled' occurs after the
DescribeAll but before the signal has been dispatched, it will be
ignored because an 'add' signal is already pending.  When that add
signal is sent, it will contain the correct data, but the receiver will
ignore it because it already saw the action in the DescribeAll reply.

https://bugzilla.gnome.org/show_bug.cgi?id=749693
2015-06-05 12:36:36 -04:00
Ryan Lortie
eeae7950fc GActionGroup: fix an annotation
.get_action_state_type() does not return a copy.

We remove the annotation entirely because it is evident from the 'const'
on the return type.

https://bugzilla.gnome.org/show_bug.cgi?id=730168
2015-06-05 12:36:09 -04:00
Matthias Clasen
96df2727f4 win32: Make g_content_type_get_mime_type work for directories
Now that we are using inode/directory for directories, handle
this case in g_content_type_get_mime_type() as well.
2015-06-05 12:30:15 -04:00
Руслан Ижбулатов
5f0665cbbc W32: Special treatment for inode/directory mime/type
This is a hack for GLocalFileInfo to correctly get icons for directories.
Without this change content type for any W32 directory is NULL
(because there's no registry entry for "inode/directory" by default,
and in any way there's no file extension that means "directory" to put there),
and GLocalFileInfo uses content type to grab icons.

https://bugzilla.gnome.org/show_bug.cgi?id=748727
2015-06-05 12:28:09 -04:00
Matthias Clasen
9931336d2d win32: Return proper icon names
The code here was returning gtk-directory and similar names as
fallback, with a comment claiming that these are 'builtin gtk'.
But they aren't, anymore, so just return the standard names.
2015-06-05 12:26:41 -04:00
Philip Withnall
c94e4c6f03 gsettings: Add a documentation section on relocatable schemas
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-06-05 13:02:33 +01:00
Matthias Clasen
6c43b6a21a Trivial: fix a comment typo 2015-06-04 19:25:42 -04:00
Xavier Claessens
0d8dd2cf5c doc: add GTlsInteractionClass
https://bugzilla.gnome.org/show_bug.cgi?id=750344
2015-06-03 10:19:02 -04:00
Alexander Larsson
7cba800a84 GNetworkMonitorNetlink: Fix check for non-kernel messages
This code used to look at the SCM_CREDENTIALS and ignore every message
not from uid 0. However, when user namespaces are in use this does not
work, as if uid 0 is not mapped you get overflowuid instead. Right now
this means we ignore all messages in such user namespaces and glib
apps hang on startup.

We can't look at pids either, as pid 0 is returned for processes
outside your pid namespace.

Instead the correct approach is to look at the sending sockaddr and
if the port id (nl_pid) is zero, then its from the kernel.

Source:
http://lists.linuxfoundation.org/pipermail/containers/2015-May/036032.html

https://bugzilla.gnome.org/show_bug.cgi?id=750203
2015-06-03 08:52:54 +02:00
Alexander Larsson
f8273f39a1 Add GNativeSocketAddress for handling "other" addresses
Instead of just dropping address types that we're not specifically
handling we return a GNativeSocketAddress which is just a dummy
container for the stuct sockaddr.

https://bugzilla.gnome.org/show_bug.cgi?id=750203
2015-06-03 08:52:54 +02:00
Emmanuele Bassi
525bbbd6bd Do not use a string literal when a format string is expected
Otherwise we'll get compiler errors.

Based on a patch by: Vincent Le Garrec <legarrec.vincent@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=696749
2015-05-25 14:04:06 +01:00
David Shea
3bd703e9c4 Add introspection annotations to GListStore
GListStore requires that item-type be derived from GObject, so specify
that the type of the item parameters is GObject so the functions can be
used via gobject-introspection.

Add a scope parameter for the callback used during insert_sorted.
2015-05-23 22:18:14 +02:00
Matthias Clasen
074fe89f22 glib-compile-schemas: Improve an error message
Mention the expected type when failing to parse a GVariant.
2015-05-15 22:53:41 -04:00
Matthias Clasen
aecac6e1cb glib-compile-schemas: Show error positions
GMarkup provides this information, pass it on.
2015-05-15 22:41:29 -04:00
Iain Lane
fe1a2dc196 gdbus tests: wait up to 60s for gdbus-testserver to take its bus name
Previously, we waited up to 0.5s, but that can fail on slow
architectures like ARM; now we wait up to 60s in 0.1s increments.

Patch originally by Simon McVittie <simon.mcvittie@collabora.co.uk>,
modified by Iain Lane to be called earlier, to catch all testcases in a
particular test.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=724113
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Acked-by: Matthias Clasen <mclasen@redhat.com>
2015-05-14 12:11:57 +01:00
Simon McVittie
3beb67f9f3 gdbus-connection: wait up to 10s to actually send a message
We previously waited 0.25s, which should be enough even on slow machines,
but you never know; but we also now wait in 0.1s increments, so this test
should actually be faster now.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=724113
Acked-by: Matthias Clasen <mclasen@redhat.com>
2015-05-14 12:11:20 +01:00
Philip Withnall
31496767c7 gresource: Document generated C file function naming
Mention the relationship to the --c-name argument, plus the need to call
some_prefix_get_resource() to get the GResource object.
2015-05-14 08:31:22 +01:00
Philip Withnall
a8c157f92b gresource: Minor capitalisation fixes in documentation 2015-05-14 08:15:46 +01:00
Simon McVittie
45dae4b506 tests: replace most g_print() with g_printerr()
I searched all files that mention g_test_run, and replaced most
g_print() calls. This avoids interfering with TAP. Exceptions:

* gio/tests/network-monitor: a manual mode that is run by
  "./network-monitor --watch" is unaffected
* glib/gtester.c: not a test
* glib/gtestutils.c: not a test
* glib/tests/logging.c: specifically exercising g_print()
* glib/tests/markup-parse.c: a manual mode that is run by
  "./markup-parse --cdata-as-text" is unaffected
* glib/tests/testing.c: specifically exercising capture of stdout
  in subprocesses
* glib/tests/utils.c: captures a subprocess's stdout
* glib/tests/testglib.c: exercises an assertion failure in g_print()

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:56 +01:00
Simon McVittie
064183a633 GFileMonitor test: use g_test_skip() instead of g_print()
This stops it from interfering with structured stdout such as TAP.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:52 +01:00
Simon McVittie
4865538ce3 GTestDBus: use g_printerr() for status message
This avoids any possibility of interfering with test syntax (such as
TAP) on stdout. TAP specifically does not parse stderr.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Colin Walters <walters@verbum.org>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 20:24:30 +01:00
Evan Nemerson
e18e7956bf gnetworkaddress: add return type annotation to parse methods
https://bugzilla.gnome.org/show_bug.cgi?id=749180
2015-05-11 09:40:26 -07:00
Simon McVittie
bced30cfbb GDBus tests: change progress noise from "if not quiet" to "if verbose"
It seems that even after Bug #711796, these can still interfere
with TAP testing:

PASS: gdbus-proxy-threads 1 /gdbus/proxy/vs-threads
tap-driver.sh: internal error getting exit status
tap-driver.sh: fatal: I/O or internal error

Let's shut them up unless --verbose is used (which would be appropriate
when running them interactively).

Similar symptoms have been seen in Debian:
https://buildd.debian.org/status/fetch.php?pkg=glib2.0&arch=mipsel&ver=2.39.91-1&stamp=1394394568
and in Guix:
https://lists.gnu.org/archive/html/bug-guix/2014-12/msg00002.html

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=725981
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-11 16:16:50 +01:00
Simon McVittie
6f859fe21a gdbus-peer test: let GDBusServer start before notifying main thread
When running the nonce-tcp and tcp-anonymous tests in one run
of gdbus-peer, or running one of them twice via command-line options
"-p /gdbus/tcp-anonymous -p /gdbus/tcp-anonymous", the one run second
would sometimes fail to connect with ECONNRESET.

Adding more debug messages revealed that in the successful case,
g_main_loop_run() was executed in the server thread first:

 # tcp-anonymous: server thread: listening on tcp:host=localhost,port=53517
 # tcp-anonymous: server thread: starting server...
 # tcp-anonymous: server thread: creating main loop...
 # tcp-anonymous: server thread: running main loop...
 # tcp-anonymous: main thread: trying tcp:host=localhost,port=53517...
 # tcp-anonymous: main thread: waiting for server thread...

but in the failing case, the main thread attempted to connect
before the call to g_main_loop_run() in the server thread:

 # tcp-anonymous: server thread: listening on tcp:host=localhost,port=40659
 # tcp-anonymous: server thread: starting server...
 # tcp-anonymous: server thread: creating main loop...
 # tcp-anonymous: main thread: trying tcp:host=localhost,port=40659...
 # tcp-anonymous: server thread: running main loop...

(The log message "creating main loop" was immediately before
create_service_loop(), and "running main loop" was immediately
before g_main_loop_run().)

To ensure that the GDBusServer has a chance to start accepting
connections before the main thread tries to connect to it, do not
tell the main thread about the service_loop immediately, but instead
defer it to an idle.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=749079
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-05-11 14:17:55 +01:00
Simon McVittie
f42d2c1b54 gdbus-serialization: use check_serialization() instead of dbus-daemon
This test originally did not connect to the bus, which meant it was
omitted from commits like 415a8d81 that made sure none of GLib tests
rely on the presence of an existing session bus. (In particular,
Debian autobuilders don't have a session bus.)

When test_double_array() was added, environments like the Debian
autobuilders didn't catch the fact that this test relied on having a
session bus, because it is often skipped in minimal environments
due to its libdbus-1 dependency.

We don't actually need to connect to a dbus-daemon here: it's enough
to convert the message from GVariant to D-Bus serialization, and
back into an in-memory representation through libdbus. That's what
check_serialization() does, and I've verified that when I re-introduce
bug #732754 by reverting commits 627b49b and 2268628 locally, this
test still fails.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=744895
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Colin Walters <walters@verbum.org>
2015-05-08 16:03:57 +01:00
Philip Withnall
23a5352cd8 glocalfilemonitor: Emit notification on rate limit change
The changed variable was previously uninitialised in the path where the
rate limit was actually changed. This could result in the
GObject::notify signal not getting emitted.

Spotted by Coverity.

CID: #1296516

https://bugzilla.gnome.org/show_bug.cgi?id=748834
2015-05-04 13:56:42 +01:00
Ting-Wei Lan
517ce45f8e gsocketlistener: Don't double unref address
https://bugzilla.gnome.org/show_bug.cgi?id=748614
2015-05-01 23:07:45 +08:00
Chun-wei Fan
10b5a8befc Fix the thumbnail-verification Test
The third parameter of the thumnail_verify() function had been updated to
const GLocalFileStat, so update the thumbnail-verification test likewise
so that the test works properly on all supported platforms.

https://bugzilla.gnome.org/show_bug.cgi?id=711547
2015-04-22 18:56:50 +08:00
Ryan Lortie
2bb898c60f app info: tweak default application algorithm
Always run the full algorithm for a given mime type before considering
fallback types.

This includes considering installed applications capable of handling a
particular mimetype, even if such an app is not explicitly marked as
default, and there is a default app for a less-specific type.

Specifically, this often helps with cases of installing apps that can
handle a particular subtype of text/plain.  We want to take those apps
in preference to a generic text editor, even if that editor is listed as
the default for text/plain and there is no default listed for the more
specific type.

Because of the more holistic approach taken by the algorithm, it is now
more complicated, but it also means that we can do more work while
holding the lock.  In turn, that lets us avoid duplicating some strings,
which is nice.

https://bugzilla.gnome.org/show_bug.cgi?id=744282
2015-04-22 10:52:10 +01:00
Philip Withnall
bc01109618 gdbusmessage: Fix a minor memory leak on an error path
If g_dbus_message_to_blob() fails at all, it will leak its mbuf. Spotted
by running the gdbus-serialization test under Valgrind — so there is a
justification for leak-free tests after all!
2015-04-22 00:02:06 +01:00
Philip Withnall
c62f7a7d68 tests: Fix various minor memory leaks in gdbus-serialization 2015-04-21 23:55:49 +01:00
Marc-André Lureau
41acf970ac gdbus: fix out-of-bound array access
In path_rule_matches(), the given paths may be of 0-length. Do not
access memory before the array in those case. This is for example
triggered by:

test_match_rule (con, G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH, "/", "", FALSE);

in test_connection_signal_match_rules().

This bug was found thanks to GCC AddressSanitizer.

https://bugzilla.gnome.org/show_bug.cgi?id=745745
2015-04-21 22:54:34 +02:00
Arun Raghavan
812ce28d5c gsocketconnection: Fix copy-pasto in documentation
https://bugzilla.gnome.org/show_bug.cgi?id=748019
2015-04-20 09:41:28 -04:00
Simon McVittie
92331eb10a Distribute summary-xmllang-and-attrs.gschema.xml in tarballs
This is needed for "make distcheck".

Reviewed-by: Matthias Clasen <mclasen@redhat.com>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=748177
2015-04-20 14:19:52 +01:00
Руслан Ижбулатов
6a2543444c W32: use 64-bit stat for localfile size calculation
https://bugzilla.gnome.org/show_bug.cgi?id=728669
2015-04-16 19:58:05 +00:00
Matthias Clasen
21107959ab gdbus: Validate the --dest argument
Passing an nonsense string for the --dest argument can lead
to a segfault of gdbus. Thats not nice, so use our existing
validation function for bus names here.

https://bugzilla.gnome.org/show_bug.cgi?id=747541
2015-04-09 17:27:17 -04:00
Ryan Lortie
3fa0a051a4 gsettings: add test for repeated <summary> errors
Make sure error handling on repeated <summary> and <description> is
being done properly, not resulting in glib-compile-schemas throwing a
critical.

https://bugzilla.gnome.org/show_bug.cgi?id=747542
2015-04-08 22:35:35 -04:00
Ryan Lortie
7f4fdb59aa gsettings: fix schema compiler error handling
Fix a couple of issues in error handling in glib-compile-schemas.

The first problem is that, in case of repeated <summary> or
<description> tags we were still allocating a GString which was never
being freed (due to the throwing of the error resulting in immediate
termination of the parse).

The second problem is that if the repeated <summary> tag also had
attributes, we would attempt to set the GError twice.

https://bugzilla.gnome.org/show_bug.cgi?id=747542
2015-04-08 22:35:35 -04:00
Ryan Lortie
2b8f131599 gsettings: stay compatible with installed schemas
Bug 747209 introduced an error when multiple <summary> or <description>
tags are found for a single key in a GSettings schema.  This check
should have been present from the start, but it was left out because the
schema compiler doesn't include these items in the cache file.  Even
still -- part of the schema compiler's job is validation, and it should
be enforcing proper syntax here.

Repeated <summary> and <description> tags are a semi-common problem when
intltool has been misconfigured in the build system of a package, but
it's possible to imagine mistakes being made by hand as well.

The idea is that these problems would be caught during the build of a
package and maintainers would be forced to fix their build systems.

An unintended side-effect of this change, however, is that the schema
compiler started ignoring already-installed schemas that contained these
problems, when rebuilding the cache.  This means that the installation
of _any_ application would cause the regeneration of the entire cache,
with these already-installed applications being excluded.  Without the
schema in the cache, the application would crash on next startup.

The validation check in the gsettings m4 macro passes --strict to the
compiler, which is not used when rebuilding the cache after
installation.  Pass this flag down into the parser and only throw the
error in case --strict was given.  This will result in the (desired)
build failure without also causing already-installed apps to stop
functioning.

This means that we will not get even a warning about the invalid schema
file in the already-installed case, but that's fine.  There is no sense
spamming the user with these messages when they are already quite fatal
for the developer at build time.

https://bugzilla.gnome.org/show_bug.cgi?id=747472
2015-04-08 22:35:35 -04:00
Ross Lagerwall
495d864e43 docs: Fix documentation for 95d300eac5 2015-04-07 18:23:39 +01:00
Chun-wei Fan
7b8f517503 gio/gdbusproxy.c: Include gasyncresult.h
Commit f10b655 removed the inclusion of gasyncresult.h from gdbusproxy.c,
but gdbusproxy.c uses g_async_result_get_source_object(), which caused a
build warning/error.  Fix that.
2015-04-07 15:02:22 +08:00
Dan Winship
7e8d4145af gdbus: fix deadlock on message cancel/timeout
The gdbus GTask port introduced a deadlock because some code had been
using g_simple_async_result_complete_in_idle() to ensure that the
callback didn't run until after a mutex was unlocked, but in the gtask
version, the callback was being run immediately. Fix it to drop the
mutex before calling g_task_return*(). Also, tweak
tests/gdbus-connection to test this.

https://bugzilla.gnome.org/show_bug.cgi?id=747349
2015-04-06 12:22:07 -04:00
Ross Lagerwall
95d300eac5 tls: Add support for copying session data
Add support for copying session data between client connections.
This is needed for implementing FTP over SSL. Most servers use a separate
session for each control connection and enforce sharing of each control
connection's session between the related data connection.

Copying session data between two connections is needed for two reasons:
1) The data connection runs on a separate port and so has a different
server_identity which means it would not normally share the session with
the control connection using the session caching currently implemented.
2) It is typical to have multiple control connections, each of which
uses a different session with the same server_identity, so only one of
these sessions gets stored in the cache. If a data connection is opened,
(ignoring the port issue) it may try and reuse the wrong control
connection's session, and fail.

This operation is conceptually the same as OpenSSL's SSL_copy_session_id
operation.

https://bugzilla.gnome.org/show_bug.cgi?id=745255
2015-04-06 14:54:12 +01:00
Paolo Borelli
b64e2956f6 Add an event signal to GSocketListener
This allows the caller to know when a socket has been bound so that
it can for instance set the SO_SENDBUF and SO_RECVBUF socket options
before listen is called

https://bugzilla.gnome.org/show_bug.cgi?id=738207
2015-04-04 21:26:15 +02:00
Dan Winship
ec9c248d7d gio: deprecate GSimpleAsyncResult
GTask has been around for a long time now, everything in GLib is using
it, and the run-in-thread deadlock problems should be fixed now.

https://bugzilla.gnome.org/show_bug.cgi?id=661767
2015-04-04 10:16:52 -04:00
Dan Winship
f10b6550ff gio: (belatedly) port gdbus from GSimpleAsyncResult to GTask
https://bugzilla.gnome.org/show_bug.cgi?id=661767
2015-04-04 10:16:45 -04:00
Dan Winship
e2655cd455 tests: clean up / ignore some more generated files 2015-04-04 10:00:39 -04:00
Dan Winship
86866a2a6d gtask: remove hardcoded GTask thread-pool size
GTask used a 10-thread thread pool for g_task_run_in_thread() /
g_task_run_in_thread_sync(), but this ran into problems when task
threads blocked waiting for another g_task_run_in_thread_sync()
operation to complete. Previously there was a workaround for this, by
bumping up the thread limit when that case was detected, but deadlocks
could still happen if there were non-GTask threads involved. (Eg, task
A sends a message to thread X and waits for a response, but thread X
needs to complete task B in a thread before returning the response to
task A.)

So, allow GTask's thread pool to be expanded dynamically, by watching
it from the glib worker thread, and growing it (at an
exponentially-decreasing rate) if too much time passes without any
tasks completing. This should solve the deadlocking problems without
causing sudden breakage in apps that assume they can queue huge
numbers of tasks at once without consequences.

https://bugzilla.gnome.org/show_bug.cgi?id=687223
2015-04-04 09:27:50 -04:00
Matthias Clasen
b2734d762f glib-compile-schema: Don't accept duplicate docs
This schema compiler was completely ignoring <summary> and
<description> tags. Unfortunately, there are modules out there
who merge translations for these back in, with xml:lang. And
this is giving dconf-editor a hard time. Since this is not
how translations of schemas are meant to be done, just
reject such schema files.

Also add tests exercising the new error handling.

https://bugzilla.gnome.org/show_bug.cgi?id=747209
2015-04-01 18:55:54 -04:00
alex94puchades
1f1fa69375 Make glib-compile-resources a little smarter
glib-compile-resources was guessing a filename ending
in .c when generating sources, but did not do the same
for headers. Fix it so it generates a .h file when
guessing the filename for headers.

https://bugzilla.gnome.org/show_bug.cgi?id=746753
2015-03-29 15:26:19 -04:00
Matthias Clasen
61a105b883 Clarify a confusing string
Relative was repeated twice here, when clearly what was meant is
relative or absolute. Pointed out in
https://bugzilla.gnome.org/show_bug.cgi?id=726447
2015-03-29 11:43:52 -04:00
Ryan Lortie
fd40b5942d inotify: fix move event matching accounting
The hash table stores the list of unmatched IN_MOVE_FROM events, but we
were removing entries from it when popping IN_MOVE_TO events.

Fix that up to correct a crash in nautilus due to the assertion failure
below.

https://bugzilla.gnome.org/show_bug.cgi?id=746749
2015-03-26 14:56:25 -04:00
Ryan Lortie
706c4d32ad file monitors: fix a typo
Due to a typo, a rename reported via a pair of delete/create events (due
to the watcher not giving the flag for moves to be paired) was
accidentally reported as being created with the old name instead of the
new name.

Fix that.
2015-03-25 23:08:38 -04:00
Ryan Lortie
4a292721bc GListModel: roll back use of type redefinition
We declare the typedefs for GListModel and GListStore in giotypes.h, as
a matter of convention.  This is not actually required, since the
typedef is emitted as part of the G_DECLARE_* macros.

The giotypes.h approach is only used to avoid cyclic dependencies
between headers, which is not a problem in this case.

Type redefinition is a C11 feature, and although it was around in some
compilers before then, gcc 4.2.1 (from 2007) is apparently still in wide
use, being the default compiler for OpenBSD.

Eventually, we will probably hit a case where we actually need to
redefine a type, but since we're not there yet, let's back off a bit.
2015-03-25 09:37:01 -04:00
Philip Withnall
1b22df7822 gsocket: Document FD ownership with g_socket_new_from_fd()
https://bugzilla.gnome.org/show_bug.cgi?id=730188
2015-03-21 13:37:17 -04:00
Chun-wei Fan
671292bbb2 Win32: Port Directory Monitoring to New GLocalFileMonitor
This WIP patch moves the Windows Directory Monitoring code to the new
GLocalFileMonitor mechanism, and adds file monitoring in the process.

Progress from previous patch:
-File renames are now properly supported, but G_FILE_MONITOR_EVENT_MOVED_IN
 and G_FILE_MONITOR_EVENT_MOVED_OUT needs to be investigated, as
 ReadDirectoryChangesW() seems to send FILE_ACTION_REMOVED when a file is
 moved out of a directory.
-Events are handled for both the long and short (8.3) variants of the
 filenames, and files monitored will report changes when it is changed
 via its short or long filenames.

Things to be done:
-Perhaps find out about attribute changes in files in a monitored
 directory; if a file is monitored, attribute changes are correctly
 handled.
-Investigate on G_FILE_MONITOR_EVENT_MOVED_OUT,
 G_FILE_MONITOR_EVENT_MOVED_IN, G_FILE_MONITOR_EVENT_PRE_UNMOUNT,
 G_FILE_MONITOR_EVENT_UNMOUNTED.
-Investigate on the "boredom" algoritm, and see how we can do it on
 Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=730116
2015-03-20 12:01:35 -04:00
Ryan Lortie
d682df186e file monitors: rewrite FAM file monitor
Completely rewrite the FAM file monitor.  Major changes:

 - now runs in the worker thread

 - dispatches events in a threadsafe way via GFileMonitorSource

 - uses unix fd source instead of a GIOChannel

 - is now simple enough to fit into one short file
2015-03-20 12:01:35 -04:00
Ryan Lortie
21ab660cf8 fen: remove Solaris file monitor support
This code is unmaintained and we have no way to port it to the new file
monitoring API.
2015-03-20 12:01:35 -04:00
Ryan Lortie
641b98ce6b kqueue backend: port to new GLocalFileMonitor API
This is the bare minimal effort.  This seems not to crash immediately,
but it definitely needs some better testing.

The backend is not in good shape.  It could use some serious work.
2015-03-20 12:01:35 -04:00
Ryan Lortie
19522424b1 GPollFileMonitor: use thread default main context
Attach the GPollFileMonitor to the thread default main context instead
of the global default.

This matches the behaviour of the other file monitors.
2015-03-20 12:01:35 -04:00
Ryan Lortie
c5d5e2916b inotify: implement "boredom" algorithm
Use the "interesting" value from g_file_monitor_source_handle_event() to
decide if we're currently being flooded by a stream of boring events.

The main case here is when one or more files is being written to and the
change events are all being rate-limited in the GFileMonitor frontends.

In that case, we become "bored" with the event stream and add a backoff
timeout.  In the case that it is exactly one large file being written
(which is the common case) then leaving the event in the queue also lets
the kernel perform merging on it, so when we wake up, we will only see
the one event.  Even in the case that the kernel is unable to perform
merging, the context switch overhead will be vastly reduced.

In testing, this cuts down on the number of wake ups during a large file
copy, by a couple orders of magnitude (ie: less than 1% of the number of
wake ups).
2015-03-20 12:01:35 -04:00
Ryan Lortie
9adf948a2b GFileMonitorSource: return "interesting" value
Return an "interesting" boolean from the event handler function on
GFileMonitorSource.

An event was "interesting" if it will result in a signal actually being
dispatched to the user.  It is "uninteresting" if it only hit an
already-dirty rate limiter.

We will use this information to do some backing off in the backends when
faced with a flood of uninteresting events.
2015-03-20 12:01:34 -04:00
Ryan Lortie
3d2d4b8efe inotify: send CHANGES_DONE when new files 'appear'
We generally assume that an IN_CREATE event is the start of a series of
events in which another process is doing this:

  fd = creat (...)         -> IN_CREATE
  write (fd, ..)           -> IN_MODIFY
  write (fd, ..)           -> IN_MODIFY
  close (fd)               -> IN_CLOSE_WRITE

and as such, we use the CHANGES_DONE_HINT event after CREATED in order
to show when this sequence of events has completed (ie: when we receive
IN_CLOSE_WRITE when the user closes the file).

Renaming a file into place is handled by IN_MOVED_FROM so we don't have
to worry about that.

There are many other cases, however, where a new file 'appears' in a
directory in its completed form already, and the kernel reports
IN_CREATE.  Examples include mkdir, mknod, and the creation of
hardlinks.  In these cases, there is no corresponding IN_CLOSE_WRITE
event and the CHANGES_DONE_HINT will have to be emitted by an arbitrary
timeout.

Try to detect some of these cases and report CHANGES_DONE_HINT
immediately.

This is not perfect.  There are some cases that will not be reliably
detected.  An example is if the user makes a hardlink and then
immediately deletes the original (before we can stat the new file).
Another example is if the user creates a file with O_TMPFILE.  In both
of these cases, CHANGES_DONE_HINT will still eventually be delivered via
the timeout.
2015-03-20 12:01:34 -04:00
Ryan Lortie
2737ab3201 substantially rework file monitors
Remove all event merging and dispatch logic from GFileMonitor.  The only
implementation of GFileMonitor outside of glib is in gvfs and it already
does these things properly.

Get rid of GLocalDirectoryMonitor.  We will use a single class,
GLocalFileMonitor, for both directory and file monitoring.  This will
prevent every single backend from having to create two objects
separately (eg: ginotifydirectorymonitor.c and ginotifyfilemonitor.c).

Introduce GFileMonitorSource as a thread-safe cross-context dispatch
mechanism.  Put it in GLocalFileMonitor.  All backends will be expected
to dispatch via the source and not touch the GFileMonitor object at all
from the worker thread.

Remove all construct properties from GLocalFileMonitor and remove the
"context" construct property from GFileMonitor.  All backends must now
get the information about what file to monitor from the ->start() call
which is mandatory to implement.

Remove the implementation of rate limiting in GFileMonitor and add an
implementation in GLocalFileMonitor.  gvfs never did anything with this
anyway, but if it wanted to, it would have to implement it for itself.
This was done in order to get the rate_limit field into the
GFileMonitorSource so that it could be safely accessed from the worker
thread.

Expose g_local_file_is_remote() internally for NFS detection.

With the "is_remote" functionality exposed, we can now move all
functions for creating local file monitors to a proper location in
glocalfilemonitor.c

Port the inotify backend to adjust to the changes above.  None of the
other backends are ported yet.  Those will come in future commits.
2015-03-20 11:59:47 -04:00
Ryan Lortie
779c809a3d inotify: rewrite inotify-kernel
Remove the hardwired 1 second event queue logic from inotify-kernel and
replace it with something vastly less complicated.

Events are now reported as soon as is possible instead of after a
delay.

We still must delay IN_MOVED_FROM events in order to look for the
matching IN_MOVED_TO events, and since we want to report events in order
this means that events behind those events can also be delayed.  We
limit ourselves, however:

 - no more than 100 events can be delayed at a time

 - no event can be delayed by more than 10ms

https://bugzilla.gnome.org/show_bug.cgi?id=627285
2015-03-20 11:58:42 -04:00
Ryan Lortie
fd8b45eb67 GLocalFile: add _new_from_dirname_and_basename
Add a new internal constructor for GLocalFile (which itself is private).

This new constructor allows creating a GLocalFile from a dirname and a
basename, assuming that the dirname is already in canonical form and the
basename is a regular basename.

This will be used for creating GLocalFile instances from the file
monitoring code (for signal emissions).
2015-03-20 11:58:42 -04:00
Jasper St. Pierre
93c8cbcfcd Update .gitignore 2015-03-18 14:28:14 -07:00
Ryan Lortie
0de16c98f7 ContextSpecificGroup: some fixups
For all of the effort spent ensuring that this algorithm would be
correctly threadsafe, I messed up the order of operations within a
single thread when porting to the new approach.

Fix that up.

Also: fix some overzealous asserting in the testcases.  Since shutdown
is now lazy, we can never surely say !is_running at any particular point
in time.
2015-03-13 17:39:50 -04:00
Ryan Lortie
bf19b8e6c3 gio docs: remote errant colon from docstring
This does not belong there.
2015-03-12 17:01:00 -04:00
Ryan Lortie
d9de830b65 Convert remaining uses of 'Rename to:'
This was replaced by (rename-to) in 2013 (see bug 676133).

They're also causing gtk-doc trouble, so let's get rid of them.
2015-03-12 16:55:22 -04:00
Ryan Lortie
eff505ed3c docs: more cleanups for GIO 2015-03-12 16:43:02 -04:00
Xavier Claessens
15a4af545e Doc: Mark a few things as private 2015-03-12 16:09:14 -04:00
Philip Withnall
4f1f68e6be gtask: Add a GTask:completed property
This can be used to query whether the task has completed, in the sense
that it has had a result set on it, and has already – or will soon –
invoke its callback function.

Notifications for this property are emitted immediately after the task’s
main callback, in the same main context as that callback. This allows
for multiple bits of code to listen for completion of the GTask, which
opens the door for blocking on cancellation of the GTask and improved
handling of ‘pending’ behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=743636
2015-03-10 08:37:45 +00:00
Dan Winship
6ce79e586f GSocketClient: fix handling of application proxies
g_socket_client_add_application_proxy() claimed "When the indicated
proxy protocol is returned by the #GProxyResolver, #GSocketClient will
consider this protocol as supported but will not try to find a #GProxy
instance to handle handshaking." But in fact, it did the checks in the
wrong order, so GProxy proxies ended up overriding
application-specified ones. Fix that.

Also, simplify the code a bit by making use of g_hash_table_add() and
g_hash_table_contains().

https://bugzilla.gnome.org/show_bug.cgi?id=733876
2015-03-06 16:01:07 -05:00
Paolo Borelli
ed4a742946 HTTP proxy support
Based on code from "WockyHttpProxy" written by Nicolas Dufresne
and Marc-André Lureau. Initial glib patch by Brian J. Murrell.

https://bugzilla.gnome.org/show_bug.cgi?id=733876
2015-03-06 21:23:58 +01:00
Chun-wei Fan
6fe28eef3c Windows: Use Standard Networking Functions If Possible
Currently, the Windows code use Winsock2-specific APIs to try to emulate
calls such as inet_pton(), inet_ntop() and if_nametoindex(), which may not
do the job all the time.  On Vista and later, Winsock2 does provide a
proper implementation for these functions, so we can use them if they exist
on the system, by querying for them during g_networking_init().  Otherwise,
we continue to use the original code path for these, in the case of XP and
Server 2003.

This enables many of the network-address tests to pass on Windows as a
result, when the native Winsock2 implementations can be used.

https://bugzilla.gnome.org/show_bug.cgi?id=730352
2015-03-06 23:40:03 +08:00
ria.freelander@gmail.com
ec1edef3ab gfdonotificationbackend: support themed icons
The spec allows setting the "image-path" hint to an icon name as well.

https://bugzilla.gnome.org/show_bug.cgi?id=745634
2015-03-05 14:54:33 +01:00
Chun-wei Fan
b9c8cecc9d gresolver.c: Windows: Fix IPv6 Address Handling
Check the IPv6 addresses on Windows, as we need to reject those that have
brackets/ports around them as valid addresses in this form would have been
accepted during the call to g_inet_address_new_from_string ().

https://bugzilla.gnome.org/show_bug.cgi?id=730352
2015-03-05 12:44:31 +08:00
Marc-Antoine Perennou
fecec08702 gio: add some missing autocleanup
https://bugzilla.gnome.org/show_bug.cgi?id=745589

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2015-03-04 14:08:19 +01:00
Philip Withnall
430814992d docs: Expand introduction to mention using async calls over sync ones
As discussed on the mailing list (see the whole thread):
    https://mail.gnome.org/archives/desktop-devel-list/2015-February/msg00126.html

Expand the GIO documentation introduction to talk a little about when to
use async and sync functions, and how the former should almost always be
preferred over the latter.

Link to this from the GFile documentation, which is an entry point for a
lot of async calls.

https://bugzilla.gnome.org/show_bug.cgi?id=744722
2015-03-03 18:27:45 +00:00
Ryan Lortie
8c104a01e1 GContextSpecificGroup: fix deadlock
There was a theoretical deadlock between the worker trying to emit a
signal at the same time as we were waiting for it to shutdown the
notification (while holding the lock).

The deadlock was particularly annoying because we didn't really need to
wait for the shutdown and because it wasn't possible to signals to
arrive while waiting for a start.  Attempting to deal with start and
stop in an asymmetric way could have lead to other weird situations,
however.

Drop the lock while waiting for the worker thread to start.  This means
that we face the possibility of multiple waiters on the cond at the same
time, so we need to make more of a state machine.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
88745c2fa7 tests: add some tests for GContextSpecificGroup
https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
548c165a9f Make GUnixMountMonitor per-context
GUnixMountMonitor was not threadsafe before.  It was a global singleton
which emitted signals in the first thread that happened to construct it.

Move it to a per-context singleton model where each GMainContext gets
its own GUnixMountMonitor.  Monitor for the changes from the GLib worker
thread and dispatch the results to each context with an active monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
ae38d2bfa4 gunixmounts: move GUnixMountMonitor code
Move this code to the correct part of the file.

While we're at it, drop an unused #define MOUNT_POLL_INTERVAL.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
f535218f70 gunixmounts.c: add fold markers
This is a large file with a lot of very complicated code in it.  Add
some fold markers to make things a bit more manageable.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
3167c6124c Deprecate g_unix_mount_monitor_set_rate_limit()
Deprecate g_unix_mount_monitor_set_rate_limit() and turn it into a
no-op.

This function doesn't behave as advertised.  It only controls rate
limiting for filesystem-based monitors.  It has no impact over reporting
mount changes on Linux, for example, because those are based on polling
for changes in /proc (which doesn't use filesystem monitors).  It also
has no impact on Mac OS because a library interface is used there.

This was added in https://bugzilla.gnome.org/show_bug.cgi?id=521946 in
order to be used by HAL, which is effectively dead.  udisks no longer
uses this code at all.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
73d4e6f12f Rename g_unix_mount_monitor_new() to _get()
This is a singleton, but we have a function called _new() to get it.
What's worse is that the documentation makes no mention of this, and
actually specifically says that a new monitor will be created each time.

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
720274511b GAppInfoMonitor: port to GContextSpecificGroup
https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
c90b083fa8 Add internal helper GContextSpecificGroup
Add a new internal helper called GContextSpecificGroup.

This is a mechanism for helping to maintain a group of context-specific
monitor objects (eg: GAppInfoMonitor, GUnixMountMonitor).

https://bugzilla.gnome.org/show_bug.cgi?id=742599
2015-03-02 15:10:46 -05:00
Ryan Lortie
0cb75bf796 GApplication: don't iterate further on _quit()
If someone explicitly calls g_application_quit() then don't attempt to
drain the mainloop of remaining sources.

This allows applications with 100% CPU utilisation to quit reliably.

https://bugzilla.gnome.org/show_bug.cgi?id=744876
2015-03-02 11:55:33 -05:00
Rico Tzschichholz
eb92b4fdff gio: Add some missing type annotations to object arguments
Similar to https://bugzilla.gnome.org/show_bug.cgi?id=745239
2015-03-01 18:12:09 +01:00
Ryan Lortie
71642ce766 tests: only chmod autorun.exe on UNIX
We install win32-software/autorun.exe (as test data for mime scanning)
only on UNIX builds, so don't attempt to chmod it on 'make install'
unless we're on UNIX.
2015-03-01 00:50:09 -05:00
Evan Nemerson
3f596074a9 GPropertyAction: add type annotation to constructor's object argument
https://bugzilla.gnome.org/show_bug.cgi?id=745239
2015-02-26 10:52:14 -08:00
Philip Withnall
e966cc51de gcancellable: Mention nullability in g_cancellable_cancel() docs
Calling g_cancellable_cancel(NULL) is an explicitly allowed no-op, for
convenience. Document and annotate that.
2015-02-24 10:57:14 +00:00
Colin Walters
0550708ca7 tests: Add many autoptr tests
I love Emacs keyboard macros, used them to convert the list of
defines cleverly into a list of tests, then iterated and filled in
the necessary constructor arguments.
2015-02-23 10:40:40 -05:00
Ryan Lortie
2844f239f6 GApplication: let the main loop drain on shutdown
After ::shutdown, run the mainloop until all pending activity is
handled, before returning from run().

Among other things, this gives a chance for destroyed windows to be
properly withdrawn from the windowing system.

https://bugzilla.gnome.org/show_bug.cgi?id=744876
2015-02-22 19:14:03 -05:00
Colin Walters
f141607eec gfileenumerator: Convert docbook tag -> markdown
This code predated the markdown conversion.  Pointed out by mclasen.
2015-02-20 14:37:39 -05:00
Colin Walters
52cd62d946 filenumerator: Add g_file_enumerator_iterate()
This is *significantly* more pleasant to use from C (while handling
errors and memory cleanup).

While we're here, change some ugly, leaky code in
tests/desktop-app-info.c to use it, in addition to a test case
in tests/file.c.

https://bugzilla.gnome.org/show_bug.cgi?id=661554
2015-02-20 14:02:05 -05:00
Philip Withnall
9b03587707 gliststore: Add missing parameter documentation 2015-02-19 14:04:05 +00:00
Lars Uebernickel
2b27382596 gapplication: test setting and binding busy state
https://bugzilla.gnome.org/show_bug.cgi?id=744756
2015-02-19 08:39:55 +01:00
Lars Uebernickel
b4ef6d957f gapplication: add "is-busy"
A property to query the current busy state of an application.

https://bugzilla.gnome.org/show_bug.cgi?id=744756
2015-02-19 08:39:55 +01:00
Ryan Lortie
6ef0664017 gapplication: stop using deprecated API
More fallout from the GOptionGroup binding patch.
2015-02-18 16:45:59 -05:00
Lars Uebernickel
2d3d8cdce2 gapplication: tune busy-binding
g_application_bind_busy_property() had the restriction that only one
property can be bound per object, so that NULL could be used to unbind.
Even though this is enough for most uses, it is a weird API.

Lift that restriction and add an explicit unbind function.

https://bugzilla.gnome.org/show_bug.cgi?id=744565
2015-02-18 20:17:03 +01:00
Ryan Lortie
07ae2e1278 tests: add GSimpleIOStream async close tests
Just a couple of tests to make sure the two paths are working properly,
without crashes or leaks.

https://bugzilla.gnome.org/show_bug.cgi?id=741630
2015-02-17 16:27:46 -05:00
Ignacio Casal Quinteiro
d4e3b82a93 Add GSimpleIOStream class
GSimpleIOStream represents an object that wraps an input and an output
stream making easy to use them by calling the #GIOStream methods.

https://bugzilla.gnome.org/show_bug.cgi?id=741630
2015-02-17 16:27:46 -05:00
Ryan Lortie
c2c0a6ae5c GIOStream: support for unemulated async close()
Add an implementation of non-thread-emulated async close of a GIOStream
if either of the underlying stream objects support it.

This prevents us from calling close() functions from another thread on
an object that may not be expecting that.  It also allows us to skip the
thread entirely in case our objects support a pure async close.

https://bugzilla.gnome.org/show_bug.cgi?id=741630
2015-02-17 16:17:01 -05:00
Ryan Lortie
cb40c553ae streams: add private 'async close via threads' API
Add an internal helper to find out if close_async() is implemented via
threads using the default implementation in the base class.

We will use this to decide if we should do a 'pure async' close of a
GIOStream or not.

https://bugzilla.gnome.org/show_bug.cgi?id=741630
2015-02-17 16:17:01 -05:00
Ryan Lortie
f56f1ef074 streams: de-gtkdocify internal API
Remove the /** **/-style block from two internal helpers to prevent
gtk-doc from picking them up.

https://bugzilla.gnome.org/show_bug.cgi?id=741630
2015-02-17 16:17:01 -05:00
Marc-André Lureau
512e9b3b34 gdbus: delay closing stream after read finish
Closing the stream on the writing side my race with a pending read. This
patch ensures that closing is delayed after reading is finished.

https://bugzilla.gnome.org/show_bug.cgi?id=743990
2015-02-17 16:16:52 -05:00
Ryan Lortie
c7f0ea4354 tests: check for NULL before g_object_unref()
delayed_close_free() calls g_object_unref() on a variable that is
expected to possibly contain NULL (as indicated by the fact that the
NULL case is handled in my_slow_close_output_stream_close_async()).

This is dead code right now (due to a bug in GDBus), which is why it
isn't actually causing a failure.  It should still be fixed, however.

https://bugzilla.gnome.org/show_bug.cgi?id=743990
2015-02-17 16:16:52 -05:00
Lars Uebernickel
fcb30409ec gapplication: never set the prgname to the app id
GApplication set the prgname to the application's id when it was running
in service mode. This broke with the addition of new --app-id option,
because g_set_prgname() was called before parsing the options. Calling
it after option parsing doesn't work, because GOptionContext sets
prgname to argv[0] unconditionally.

Instead of changing the semantics of GOptionContext, simply remove this
functionality from GApplication. It is very unusual to have the prgname
set to the app id instead of the binary's name and might confuse people
when looking at logs etc.

When overriding local_command_line() from a subclass,
g_option_context_parse() might never be invokded. Thus, continue setting
the prgname to argv[0] in GApplication.

https://bugzilla.gnome.org/show_bug.cgi?id=743933
2015-02-17 19:09:47 +01:00
Lars Uebernickel
0f2b54142a gapplication: add bind_busy_property()
Balancing g_application_{un,}mark_busy() is non-trivial in some cases.

Make it a bit more convenient by allowing to bind multiple boolean
properties (from different objects) to the busy state. As long as these
properties are true, the application is marked as busy.

https://bugzilla.gnome.org/show_bug.cgi?id=744565
2015-02-16 07:38:43 +01:00
Jasper St. Pierre
56f0c637cf Update .gitignore 2015-02-10 11:50:59 -08:00
Xavier Claessens
b5538416c0 GListModel: Use G_DECLARE_INTERFACE
https://bugzilla.gnome.org/show_bug.cgi?id=743939
2015-02-06 12:18:44 +01:00
Xavier Claessens
74c22150cf docs: fix up docs issues in gio/ 2015-02-05 16:20:43 +01:00
Ryan Lortie
7417198e4e docs: fix typo in g_settings_new_full() docstring 2015-02-04 16:30:24 +01:00
Xavier Claessens
caf9db2dfb Doc: Fix GListModel/GListStore 2015-02-04 15:07:14 +01:00
Lars Uebernickel
c1b0f178ca GListStore: fix preconditions in insert_sorted() 2015-02-03 16:08:37 +01:00
Ryan Lortie
26af7c152f tests: add test for GListStore inserted sort
https://bugzilla.gnome.org/show_bug.cgi?id=743927
2015-02-03 15:46:48 +01:00
Ryan Lortie
3f3eac474b GListStore: add sorted insert function
Add g_list_store_insert_sorted() which takes a GCompareDataFunc to
decide where to insert.  This ends up being a very trivial function,
thanks to GSequence.

https://bugzilla.gnome.org/show_bug.cgi?id=743927
2015-02-03 15:46:48 +01:00
Chun-wei Fan
ccf696a6e1 glistmodel.h: Fix _GListModelInterface Define
"interface" is a reserved word on Visual Studio, so fix the build by
using g_iface instead.

https://bugzilla.gnome.org/show_bug.cgi?id=743827
2015-02-02 11:16:45 +01:00
Ryan Lortie
e2f8afdd85 gio: add support for g_auto() and g_autoptr()
Add support to libgio types for the new cleanup macros.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
2015-01-30 16:58:40 +01:00
Ryan Lortie
93982d4a16 giotypefuncs test: tweak _get_type() regexp
Make sure that we only match the _get_type() function name by
restricting the regexp to matching [A-Za-z0-9_].  We were matching on .*
before which means that if we had two _get_type() functions appearing on
a single line then we would get everything in between them included (by
the default rule of '*' being greedy).

This affected G_DECLARE_*_TYPE which puts several uses of _get_type()
into a single line.
2015-01-30 15:30:02 +01:00
Lars Uebernickel
b69beff426 Add GListModel
GListModel is an interface that represents a dynamic list of GObjects.

Also add GListStore, a simple implementation of GListModel that stores
all objects in memory, using a GSequence.

https://bugzilla.gnome.org/show_bug.cgi?id=729351
2015-01-30 15:08:57 +01:00
Lars Uebernickel
6d55189d8c gsettings: add g_settings_schema_list_children
https://bugzilla.gnome.org/show_bug.cgi?id=743517
2015-01-28 18:09:28 +00:00
Lars Uebernickel
d95bb1f08b gsettings: add g_settings_schema_key_get_name
https://bugzilla.gnome.org/show_bug.cgi?id=743517
2015-01-28 18:09:28 +00:00
Dan Winship
e8d3f29300 gcredentialsprivate: clarify the USE_FREEBSD_CMSGCRED users
Add comments clarifying what the three non-FreeBSD platforms using
G_CREDENTIALS_USE_FREEBSD_CMSGCRED are.
2015-01-27 07:38:31 -05:00
Peeter Must
4c54b9fe31 gcredentials: Add support for DragonFly
https://bugzilla.gnome.org/show_bug.cgi?id=743508
2015-01-27 07:31:24 -05:00
Cosimo Cecchi
be2d9b4f58 GSimpleAction: add g_simple_action_set_state_hint
Currently the only way to set a state hint on an action is through a
subclass; add a g_simple_action_set_state_hint() method so that this
becomes easier for clients that already use GSimpleAction.

https://bugzilla.gnome.org/show_bug.cgi?id=743521
2015-01-26 12:06:24 +00:00
Chun-wei Fan
ef09373e03 gio/Makefile.am: Fix MSVC Project Generation
We need to filter out gnetworkmonitornm.c in the MSVC Projects, as that is
UNIX-only code.
2015-01-21 14:28:47 +08:00
Ignacio Casal Quinteiro
cf03e82478 gsocket: always try before waiting for condition
When implementing blocking operations on top of
nonblocking sockets we should always first try to
perform the operation and then if needed handle
EAGAIN and wait with g_socket_wait_condition.
This is an optimization since we avoid calling
wait condition when it is not needed, but most
importantly this fixes hangs on win32 where some
events (in particular FD_WRITE) are only emitted
after the operation fails with EWOULDBLOCK.

https://bugzilla.gnome.org/show_bug.cgi?id=732439
https://bugzilla.gnome.org/show_bug.cgi?id=741707
2015-01-17 15:04:25 +01:00
Paolo Borelli
4f4714285d gsocket: add a testcase that shows a hang on win32
Add a unit test that checks g_socket_new_from_fd by creating
a gsocket, obtaining its fd, duplicating the fd and then creating
a gsocket from the new fd. This shows a hang on win32 since the
gsocket created from the fd never receives the FD_WRITE event
because we wait for the condition without first trying to write
and windows signals the condition only after a EWOULDBLOCK error.

https://bugzilla.gnome.org/show_bug.cgi?id=741707
2015-01-17 15:04:25 +01:00
Philip Withnall
70e2630f5a gsettings: Fix a typo in the GSettings documentation
https://bugzilla.gnome.org/show_bug.cgi?id=741788
2015-01-14 10:53:04 +00:00
Iain Lane
f7be461601 gnetworkmonitornm: Check if network-manager is running
We were asking for properties on NM's dbus interface, but if NM is not
running then there won't be any. Check if the name has an owner before
doing anything to it.

https://bugzilla.gnome.org/show_bug.cgi?id=741653
2015-01-13 12:11:06 +01:00
Timm Bäder
327d35ed41 gnetworkmonitornm: Prevent crash
g_dbus_proxy_get_cached_property_names can return NULL if there are no
cached properties, so don't try to access them in that case.
2015-01-05 11:51:46 +01:00
TingPing
aa4e2d4dc3 Fix GContentType usage
https://bugzilla.gnome.org/show_bug.cgi?id=734946
2015-01-04 22:09:37 -05:00
Erick Pérez Castellanos
8344bf1179 Fix document typo
This one was making syntax highlighting fail.
2014-12-22 11:02:08 -05:00
Philip Chimento
4f3ab40c04 gfile: Explain nonobvious use of my_error
In g_file_make_directory_with_parents(), the my_error variable is used
for several different purposes throughout the whole function, not all of
which are obvious. This explains the situation with some comments.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Philip Chimento
44372f4dd0 gfile: Use g_error_matches
Make proper use of g_error_matches() instead of comparing only error codes.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Philip Chimento
5a7db3015a gfile: make_directory_with_parents race condition
A race condition could cause g_file_make_directory_with_parents() to
fail with G_IO_ERROR_EXISTS despite the requested directory not
existing.

https://bugzilla.gnome.org/show_bug.cgi?id=719455
2014-12-18 02:02:53 -05:00
Dan Winship
b6d1c66c50 gio/tests/socket: fix one of the new tests
One of the recently-added tests was using g_test_cmpstr() on a buffer
containing a string that wasn't necessarily 0-terminated.
2014-12-14 08:04:27 -05:00
Tim-Philipp Müller
ae1b6ecd9d gio/tests/socket: add unit test for g_socket_send_messages()
https://bugzilla.gnome.org/show_bug.cgi?id=719646
2014-12-11 15:10:44 +00:00
Tim-Philipp Müller
fff5c7cd63 gsocket: add g_socket_send_messages()
Allows sending of multiple messages (packets, datagrams)
in one go using sendmmsg(), thus drastically reducing the
number of syscalls when sending out a lot of data, or when
sending out the same data to multiple recipients.

https://bugzilla.gnome.org/show_bug.cgi?id=719646
2014-12-11 15:10:44 +00:00
Tim-Philipp Müller
3c3fc0e463 gio/tests/socket: add datagram version of test_ip_sync 2014-12-11 15:10:44 +00:00
Tim-Philipp Müller
4864850427 gio/tests/socket: add test for g_socket_send_message() 2014-12-11 15:10:44 +00:00
Dan Winship
f8da414d08 gio: fix the Since/AVAILABLE version on network connectivity stuff 2014-12-10 18:39:21 +01:00
Ross Lagerwall
7d9816934e gio/tests: Prevent hangs and aborts in socket-listener
Fix two problems:
1) If g_socket_service_stop is called before the accept call is requeued,
then the reference count won't decrease and this code will hang forever:
  while (G_OBJECT (service)->ref_count == ref_count)
    g_main_context_iteration (NULL, TRUE);

2) Sometimes the testcase fails (maybe 1 in 200 times for me):
GLib-GIO:ERROR:socket-listener.c:73:connection_cb: assertion failed
(G_OBJECT (service)->ref_count == 2): (3 == 2)
Aborted (core dumped)

The problem is that depending on ordering, cancellation of the async
listener can require further main context iterations before it releases
the reference on the socket service. Furthermore, in some cases, it
requires at least one iteration.

https://bugzilla.gnome.org/show_bug.cgi?id=712570
2014-12-07 08:40:18 +02:00
Bastien Nocera
485a6900fc gio: Add GNetworkMonitor impl based on NetworkManager
Which implements the new GNetworkConnectivity property.

https://bugzilla.gnome.org/show_bug.cgi?id=664562
2014-12-05 17:37:41 +01:00
Dan Winship
8d08b82109 gio: add network connectivity state to GNetworkMonitor
Add a property to GNetworkMonitor indicating the level of network
connectivity: none/local, limited, stuck behind a portal, or full.

The default implementation just returns none or full depending on the
value of is-available.

https://bugzilla.gnome.org/show_bug.cgi?id=664562
2014-12-05 17:37:41 +01:00
Bastien Nocera
ed68d80e61 gio: Correct the "available in" for GNetworkMonitor
They were marked as available in all versions when the main interface
was actually added in glib 2.32.

https://bugzilla.gnome.org/show_bug.cgi?id=664562
2014-12-05 17:37:41 +01:00
Ignacio Casal Quinteiro
e0f1a19332 gio: provide G_IO_ERROR_NOT_CONNECTED translation for ENOTCONN
https://bugzilla.gnome.org/show_bug.cgi?id=741016
2014-12-02 14:29:50 +01:00
Ignacio Casal Quinteiro
22ab227348 gio: fix build
next time I should definitely try to compile after a rebase conflict...
2014-12-02 14:29:50 +01:00
Ignacio Casal Quinteiro
fbfc23453d gio: add G_IO_ERROR_NOT_CONNECTED
It adds a new error G_IO_ERROR_NOT_CONNECTED
and makes the win32 error ERROR_PIPE_LISTENING
to be translated to it.

https://bugzilla.gnome.org/show_bug.cgi?id=741016
2014-12-02 14:21:14 +01:00
Dan Winship
967fedc0ae gsocket: add G_IO_ERROR_CONNECTION_CLOSED
Add G_IO_ERROR_CONNECTION_CLOSED as an alias for
G_IO_ERROR_BROKEN_PIPE, and also return it on ECONNRESET.

It doesn't really make sense to try to distinguish EPIPE and
ECONNRESET at the GLib level, since the exact choice of which error
gets returned in what conditions depends on the OS. Given that, we
ought to map the two errors to the same value, and since we're already
mapping EPIPE to G_IO_ERROR_BROKEN_PIPE, we need to map ECONNRESET to
that too. But the existing name doesn't really make sense for sockets,
so we add a new name.

https://bugzilla.gnome.org/show_bug.cgi?id=728928
2014-11-29 14:26:42 -05:00
Dan Winship
64f9bf96fd gnetworkaddress: Add g_network_address_new_loopback() constructor
This is a convenience method for creating a GNetworkAddress which is
guaranteed to return IPv4 and IPv6 loopback addresses. The program
cannot guarantee that 'localhost' will resolve to both types of
address, so programs which wish to connect to a local service over
either IPv4 or IPv6 must currently manually create an IPv4 and another
IPv6 socket, and detect which of the two are working. This new API
allows the existing GSocketConnectable machinery to be used to
automate that.

Based on a patch from Philip Withnall.

https://bugzilla.gnome.org/show_bug.cgi?id=732317
2014-11-29 14:22:42 -05:00
Lars Uebernickel
d511d6b37f GSettings: fix check for delaying backend subscription
g_settings_has_signal_handlers() checks whether any of the signals has
pending handlers. However, g_signal_has_handler_pending() matches on
exact detail, even when passing 0. Subscribing to one of GSettings'
signals with a detail will fail this check and never connect to the
backend.

Fix this by calling has_handler_pending() with the key as detail as
well.

https://bugzilla.gnome.org/show_bug.cgi?id=740848
2014-11-28 15:19:07 +01:00
Matthias Clasen
7f2f4ab12d Use the new g_strv_contains
No need to keep our own copy of this in the testsuite.
2014-11-27 09:12:42 -05:00
Dan Winship
e784a4ba32 gio/tests: add a socket-listener test
Add a GSocketListener test program. Currently the only test is a
regression test for bug 712570 (based on a standalone bug reproducer
provided by Ross Lagerwall).
2014-11-23 12:33:01 -05:00
Ross Lagerwall
9a6e01ea5b gio: Prevent hang when finalizing GThreadedSocketService
If all users of a GThreadedSocketService release their references to the
service while a connection thread is running, the thread function will
release the last reference to the service which causes the finalize to
deadlock waiting for all threads to finish (because it's called from the
thread function).

To fix this, don't wait for all threads to finish in the service's
finalize method.  Since the threads hold a reference to the service,
finalize should only be called when all threads are finished running (or
have unrefed the service and are about to finish).

https://bugzilla.gnome.org/show_bug.cgi?id=712570
2014-11-23 12:02:38 -05:00
Michael Henning
89e663107e gio: Implement g_win32_app_info_launch_uris for windows. 2014-11-22 17:24:51 -05:00
Michael Henning
90f0eb101f gio: Implement g_app_info_get_default_for_uri_scheme for windows. 2014-11-22 17:24:51 -05:00
Dan Winship
7f5c862e16 GTlsClientConnection: loosen the semantics of "use-ssl3"
If SSL 3.0 has been disabled (at the host, application, or library
level), then the "use-ssl3" property becomes a "fail-immediately"
property.

Despite the name, the point of the property wasn't really specifically
to use SSL 3.0; it was to allow fallback when talking to broken
servers that do SSL/TLS negotiation incorrectly and break when they
see unexpectedly-high version numbers. So if we can't fall back to SSL
3.0, then the "use-ssl3" property should fall back to TLS 1.0 instead
(since there are hosts that will reject a TLS 1.2 handshake, but
accept a TLS 1.0 one).

glib-networking is being updated to implement that behavior, so update
the documentation here.

https://bugzilla.gnome.org/show_bug.cgi?id=738633
2014-11-22 11:02:22 -05:00
Chun-wei Fan
f6bbd19beb GSettings Registry Backend: Init cache_lock Earlier
In commit 8ff5668, we are subscribing the GSettings backend later, but this
meant that we need to initialize cache_lock earlier, as we might try to
use that lock before a change notification is issued to subscribe the
backend, which would then cause an access violation if we are trying to
read GSettings values, as that lock is used to access the Windows Registry.

Initialize cache_lock once we initialize the GSettings Registry backend,
and delete it upon finalize, so that g_settings_read_from_backend() can
proceed normally, even if the GSettings backend is not yet subscribed.

https://bugzilla.gnome.org/show_bug.cgi?id=740413
2014-11-20 22:11:25 +08:00
Christian Persch
5c68fc9f93 gsettingsschema: Print the string that failed to parse
When parsing a translated value fails, print the actual string that
failed to parse instead of the 'domain\004string' untranslated string.

https://bugzilla.gnome.org/show_bug.cgi?id=737150
https://bugzilla.gnome.org/show_bug.cgi?id=737160
2014-11-20 10:38:18 +01:00
Ryan Lortie
8ff5668a45 GSettings: delay backend subscription
GSettings objects begin watching for changes as soon as they are created
in order that they can emit the "changed" signal.

In the case of dconf, if we want to be able to emit the changed signal,
we need to go on the bus and add some match rules.  This requires
creating the dconf helper thread and also requires initialising GDBus
(which creates another thread).

Some users of GSettings are never interested in the "changed" signal.
One of these users is the glib-networking code that gets run every time
a new network connection is created.

Some users are reporting that they are annoyed that simply establishing
a network connection would spawn two extra threads and create a D-Bus
connection.

In order to avoid doing unnecessary work for these simple uses, delay
the subscription until we know that we will actually need to do it.

We do this in a simple way, using a simple argument: in order for the
user to care that a value changed then they must have:

 1) watched for a change signal; and then
 2) actually read a value

If the user didn't actually read a value then they cannot possibly be
interested in if the value changed or not (since they never knew the old
value to begin with and therefore would be unable to observe that it
ever changed, since they have nothing to compare the new value with).

This really is a behaviour change, however, and it does impact at least
one user: the 'monitor' functionality of the GSettings commandline tool,
which is interested in reporting changes without ever having known the
original values.  We add a workaround to the commandline tool in order
to ensure that it continues to function properly.

It's also possible to argue that it is completely valid to have read a
value and _then_ established a change signal connection under the
(correct) assumption that it would not have been possible to miss a
change signal by virtue of not having returned to the mainloop.
Although this argument is true, this pattern is extremely non-idiomatic,
and the problem is easily avoided by doing things in the usual order.

We never really talked about change notification in the overview
documentation for GSettings, so it seems like now is a good time to add
some discussion, including the new rules for when one can expect change
signals to be emitted.

https://bugzilla.gnome.org/show_bug.cgi?id=733791
2014-11-19 13:40:09 -05:00
Lars Uebernickel
021c4ad050 gapplication: enable --help when app has options
This should already work according to the documentation, but doesn't
because main_options is consumed before the check in
g_application_parse_command_line().

Fix by moving the check for main_options up.

https://bugzilla.gnome.org/show_bug.cgi?id=740157
2014-11-15 17:35:18 +01:00
Chun-wei Fan
012c9dcd82 gnetworking.h.win32: Move "#undef interface"
This is a follow-up commit due to the fix in gnetworking.h.in in commit
7103484 (gnetworking.h.in: move "#undef interface").
2014-11-03 10:09:38 +08:00
Dan Winship
7103484017 gnetworking.h.in: move "#undef interface"
The win32 headers do:

  #define interface struct

which is just evil and breaks other code that assumes it can use
"interface" as a variable name. gnetworking.h was supposed to be doing
"#undef interface" after including the win headers, but it did it too
soon, resulting in it getting redefined by a later include. Fix this.

https://bugzilla.gnome.org/show_bug.cgi?id=738551
2014-11-02 09:36:14 -05:00
Dan Winship
982d0e11d7 GTlsCertificate: fix loading of bad certificate chains
g_tls_certificate_new_from_file() was only loading the complete chain
if it was fully valid, but we only meant to be validating that it
formed an actual chain (since the caller may be planning to ignore
other errors).

https://bugzilla.gnome.org/show_bug.cgi?id=729739
2014-11-01 17:11:25 -04:00
Ross Lagerwall
0728e62be8 doc: Clarify documentation regarding g_file_replace and etags
Clarify that with g_file_replace, a non-NULL etag is only checked if the
file already exists.

https://bugzilla.gnome.org/show_bug.cgi?id=736286
2014-10-30 20:19:14 +00:00
Ross Lagerwall
226c292b6a gio: Prevent hang writing to a large GMemoryBuffer
Fix a hang due to overflow by using unsigned numbers and explicitly
checking if the number overflows to zero.  This also fixes the previous
logic which assigned an int which may be negative to an unsigned number
resulting in sign extension and strange results.

Use gsize rather than int to allow for large buffers on 64 bit machines.

https://bugzilla.gnome.org/show_bug.cgi?id=727988
2014-10-30 20:15:47 +00:00
Ross Lagerwall
5a6f13d16f gio: Prevent hang writing to a large GMemoryOutputStream
Fix a hang due to overflow by using unsigned numbers and explicitly
checking if the number overflows to zero.  This also fixes the previous
logic which assigned an int which may be negative to an unsigned number
resulting in sign extension and strange results.

Use gsize rather than int to allow for large streams on 64 bit machines.

https://bugzilla.gnome.org/show_bug.cgi?id=727988
2014-10-30 20:15:47 +00:00
Owen W. Taylor
66fc112c74 GDBusInterfaceVTable: clarify memory handling for the method() virtual function
There are two consistent interpretations that could be taken for memory
handling of the 'invocation' parameter passed to the method_call() virtual
function of GDBusInterfaceVTable

 - A reference is passed (transfer full) to the method_call() virtual function,
   and that reference is then passed (transfer full) to the return_value/error
   functions on GDBusMethodInvocation.
 - An internal reference is retained from the point where method_call() is called
   until the return_value/error function is called.

Since the return_value/error functions were already marked (transfer full),
we use the first interpretation, annotate the invocation parameter of
method call as (transfer full) and describe this in the documentation, along
with the idea that you are always supposed to call one of the return_value/error
functions.

See bug 738122 for the leak this caused in GJS.

https://bugzilla.gnome.org/show_bug.cgi?id=738259
2014-10-28 13:57:52 -04:00
Philip Withnall
203fe3b8a8 gcancellable: Clarify that GSources hold references to GCancellables
Clarify in the documentation that a GSource created with
g_cancellable_source_new() must be explicitly removed from its
GMainContext before the GCancellable can be finalised.

This could be a common way of leaking GCancellables.

https://bugzilla.gnome.org/show_bug.cgi?id=737259
2014-10-27 09:43:55 +00:00
Erik van Pienbroek
92d6735898 Guard g_inet_address_mask_equal against invalid input
https://bugzilla.gnome.org/show_bug.cgi?id=733338
2014-10-26 11:42:53 -04:00
Dan Winship
0501bf26b9 gio/tests/tls-certificates: fix
da053e34 broke the tls-certificates test by requiring the backend to
implement g_tls_certificate_verify() (which the test TLS backend
didn't). Add a trivial implementation to make the test pass again;
we'll need something more complicated when we add tests that are
supposed to get errors.
2014-10-25 08:52:54 -04:00
Benjamin Otte
4125415e7f gfile: g_file_equal (x, x) is TRUE
So shortcut it.

I wrote this patch less as a performance optimization and more as a
clarification, so that people looking at the code can be assured of this
invariant.

https://bugzilla.gnome.org/show_bug.cgi?id=738374
2014-10-21 22:51:40 +02:00
Ryan Lortie
b768d0e4ea Add tests for {read,write}_all_async()
https://bugzilla.gnome.org/show_bug.cgi?id=737451
2014-10-21 12:09:57 -04:00
Ryan Lortie
223b5f757f docs: explain inconsistency of _{read,write}_all()
These functions are inconsistent with our normal conventions in that
they set an output variable to a specified value, even in the case that
an error is thrown.

Document very clearly that this should be considered exceptional.

https://bugzilla.gnome.org/show_bug.cgi?id=737451
2014-10-21 12:09:57 -04:00
Ryan Lortie
c8d1047093 Add g_output_stream_write_all_async()
Similar to the previous patch, this commit contains a minor violation of
normal API conventions.  See the explanation in the previous commit
message.

Heavily based on a patch from Ignacio Casal Quinteiro.

https://bugzilla.gnome.org/show_bug.cgi?id=737451
2014-10-21 12:09:57 -04:00
Ryan Lortie
76b890d0f1 Add g_input_stream_read_all_async()
Add an asynchronous version of _read_all().

This API is not fully consistent with the normal expectations of a
non-asynchronous version.  Consistency between the sync and async version is
probably more important.

The API will still bind correctly, but access to all functionality will
not be available: specifically, in the case of an error, higher level
languages will be unable to determine how many bytes were successfully
read before the error.  Most users will probably not want to use this
information anyway, so this is OK -- and if they do need the
information, then they can just write the loop for themselves.

Heavily based on a patch from Ignacio Casal Quinteiro.

https://bugzilla.gnome.org/show_bug.cgi?id=737451
2014-10-21 11:31:45 -04:00
Michael Catanzaro
aabc3a41c3 Fix another ancient docs typo 2014-10-20 19:05:48 -05:00
Ryan Lortie
f4af8d1d00 GApplication: ignore --help if not handling args
If the user didn't register any arguments for parsing, also ignore
--help.  This fixes a regression in meld.

https://bugzilla.gnome.org/show_bug.cgi?id=737869
2014-10-20 15:00:51 +02:00
Matthias Clasen
f2786908a8 GApplication: Plug a memory leak
We were not freeing resource_path.
2014-10-14 23:22:14 -04:00
Jasper St. Pierre
5a0a85e444 gdesktopappinfo: Fix copy/paste typo from e24e89b
Commit e24e89b accidentally ironically introduced a typo when replacing
the code with symbolic contents. Specifically, "Added Associations" was
replaced with "Default Applications" when reading defaults.list, giving
a warning about the file containing a "Default Applications" group.

If this was intended, it should have not been lumped in with a cleanup.
2014-10-14 19:17:53 -07:00
Benjamin Otte
e054bbfe16 gfile: Clarify docs
Clarify corner cases that were unclear while reviewing a GTK patch.
2014-10-12 01:57:02 +02:00
Matthias Clasen
de82b641b0 Add advice on g_cancellable_reset
Don't use it at home.
2014-10-06 22:41:06 -04:00
Aleix Conchillo Flaqué
da053e345b tlscertificate: add support for certificate chains
This patch changes the behavior of the following functions:

   g_tls_certificate_new_from_pem
   g_tls_certificate_new_from_file
   g_tls_certificate_new_from_files

If more than one certificate is found it will try to load the chain.

It is assumed that the chain will be in the right order (top-level
certificate will be the last one in the file). If the chain cannot be
verified, the first certificate in the file will be returned as before.

https://bugzilla.gnome.org/show_bug.cgi?id=729739
2014-10-06 10:19:48 -07:00
Bastien Nocera
e24e89bc07 gdesktopappinfo: Use symbolic names in the code
We have #defines for the key file groups, so use them to avoid typos.

https://bugzilla.gnome.org/show_bug.cgi?id=736273
2014-09-30 14:41:43 +02:00
Ting-Wei Lan
45344f3622 GCredentials: Fix ABI break when adding NetBSD support
https://bugzilla.gnome.org/show_bug.cgi?id=728256
2014-09-30 00:42:00 +08:00
Philip Withnall
f41ebebd34 gtask: Ignore errors from g_thread_pool_push()
g_thread_pool_push() only returns an error if it fails to spawn a new
thread. However, it unconditionally adds the task to its worker queue,
so:
 • if _any_ threads exist in the pool, the task will eventually be
   handled; and
 • if _no_ threads exist in the pool, the task will be handled if one
   is eventually successfully spawned.
If no more threads are ever spawned, the process probably has bigger
problems than a single GTask which is taking forever to complete.

https://bugzilla.gnome.org/show_bug.cgi?id=736806
2014-09-23 08:08:45 +01:00
Philip Withnall
925913d8dd gtask: Document signal handler reference counting
Explain why the signal handler holds a reference to the GTask, even
though that causes a reference loop at first glance.

https://bugzilla.gnome.org/show_bug.cgi?id=736806
2014-09-23 08:08:25 +01:00
Philip Withnall
c6838ffaa1 gtask: Fix a signed/unsigned integer comparison
The GSource times assigned to creation_time are always signed.

https://bugzilla.gnome.org/show_bug.cgi?id=736806
2014-09-23 08:08:25 +01:00
Matthias Clasen
174ebaefcc gresource: Make extract work better
When no section is specified, look for the resource to extract
in all sections - previously, we would stop after the first
section.
2014-09-18 15:26:36 -04:00
Matthias Clasen
5c951e5b04 gresource: Use GError in more places
The API gives us an error message, lets use it.
2014-09-18 14:52:03 -04:00
Jasper St. Pierre
38a0614225 GApplication:handle-local-options: document return value
The return value for this signal was documented in the prose, but not
properly in a Returns: stanza.  Fix that.
2014-09-16 17:49:49 -04:00
Jasper St. Pierre
84ec6b4d78 g_application_add_main_option: fix type signature
The flags argument is a GOptionFlags so use that type instead of 'int'.
2014-09-16 17:48:49 -04:00
Jasper St. Pierre
4482977238 Fix some introspection warnings 2014-09-16 14:52:21 -06:00
Sébastien Wilmet
25990eb2b6 docs: various small fixes
For the GPtrArray example, several variables declared on the same line
is harder to read and to work with (to move, remove or comment a single
variable declaration).
2014-09-13 16:59:31 +02:00
Ryan Lortie
3b8bc8bacf GDesktopAppInfo: avoid inotify on missing dirs
Some desktop file directories, like /usr/local/share/applications may be
missing on some systems.

When we try to inotify on these directories, this will result in a
every-4-seconds poll being setup which is quite bad.

This is an issue that should be fixed in inotify itself but the problem
is much larger there.  For now, we can work around it in GDesktopAppInfo
by refusing to monitor missing directories.

We may get some spurious notifications of changes in the case that
/usr/local/share or /usr/local/share/applications is created without
actually adding desktop files, but spurious changes can already be
reported in other cases, so that's OK.  We won't get (user-visible)
notification for a simple case of a completely unrelated file being
created (however we cannot avoid the wakeup in this case due to how
inotify works).  That's probably pretty theoretical, though, since files
in /usr don't change much and for the home directory we're likely to
have at least ~/.config and ~/.local existing.

https://bugzilla.gnome.org/show_bug.cgi?id=736350
2014-09-09 14:11:38 -04:00
Ryan Lortie
2f55c66c64 apps test: add new "monitor" subcommand
Waits until something modifies a desktop directory, then exits.

https://bugzilla.gnome.org/show_bug.cgi?id=736350
2014-09-09 14:11:38 -04:00
Paolo Borelli
8df2cca08a Fix minor mem leak in test case 2014-09-08 08:19:25 +02:00
Ryan Lortie
08efbda733 GDesktopAppInfo: fix default app logic
We use "tweaks" structures to track how a particular directory impacts
the list of added, removed and default applications.  We maintain this
set of tweaks for each directory, in a hash table, keyed by unaliased
mime type name, in order to facilitate fast lookups.

A typo in the logic for creating and maintaining the uniqueness of these
structures was causing the default app to be selected incorrectly from
time to time.  Fix that.
2014-09-04 14:48:05 -04:00
Patrick Welche
e763d93456 GCredentials: credentials messages are not correctly supported on NetBSD
https://bugzilla.gnome.org/show_bug.cgi?id=735819
2014-09-04 08:26:27 -04:00
Patrick Welche
369c8bd566 GUnixMounts: Improve efficiency in polling case
https://bugzilla.gnome.org/show_bug.cgi?id=583330
2014-08-27 15:08:38 +02:00
Philip Withnall
cb320cb5fe gsocketclient: Handle cancellation between CONNECTING and CONNECTED
If a g_socket_client_connect_async() operation is cancelled between the
CONNECTING and CONNECTED events (i.e. while in the
g_socket_connection_connect_async() call), the code in
g_socket_client_connected_callback() would previously unconditionally
loop round and try the next socket address from the address enumerator
(by calling enumerator_next_async()). This would correctly handle the
cancellation and return from the overall task — but not before emitting
a spurious RESOLVING event.

Avoid emitting the spurious RESOLVING event by explicitly handling
cancellation at the beginning of g_socket_client_connected_callback().

https://bugzilla.gnome.org/show_bug.cgi?id=735179
2014-08-22 19:11:26 +01:00
Jonas Danielsson
bf9c862504 GApplication: Add g_application_add_main_option
This function adds a single main option entry to be handeled by
GApplication. The option entry has it arg_data field set to NULL
and will be added to the applications packed_options.

The rationale for this is that bindings will be able to add
command line options even when they can't use the un-boxed struct
GOptionEntry.

https://bugzilla.gnome.org/show_bug.cgi?id=727455
2014-08-20 16:02:59 +02:00
Patrick Welche
4f775b7b7f GUnixMounts: Fall back to polling on systems without mtab
This is necessary for many of the BSD family at least.

https://bugzilla.gnome.org/show_bug.cgi?id=583330
2014-08-19 10:48:12 +02:00
Rico Tzschichholz
e0e52b60ea docs: Fix broken gtk-doc formatting 2014-08-18 14:08:41 +02:00
Руслан Ижбулатов
3c6efd4d50 Make sure compiled resources only have / as dirsep
https://bugzilla.gnome.org/show_bug.cgi?id=725511
2014-08-05 21:49:54 +00:00
Руслан Ижбулатов
4f73487300 Fix tests to compile again - add missing headers to W32, call correct process-id-getting function
https://bugzilla.gnome.org/show_bug.cgi?id=725513
2014-08-02 12:41:14 +00:00
Руслан Ижбулатов
42ddcc6ff2 Silence some uncontroversial warnings
https://bugzilla.gnome.org/show_bug.cgi?id=711547
2014-08-02 12:38:38 +00:00
Руслан Ижбулатов
905a8e655c Ensure critial sections are released before returning
https://bugzilla.gnome.org/show_bug.cgi?id=734035
2014-07-31 10:39:54 +00:00
David King
03b510fde1 gfile: Fix memory leak in g_file_move()
https://bugzilla.gnome.org/show_bug.cgi?id=729703
2014-07-28 14:48:23 +02:00
Ryan Lortie
2268628565 gdbus: Properly fix encoding of double arrays
It turns out that this bug actually would (sometimes) impact any sort of
fixed-sized array with an alignment requirement of 8 due to incorrectly
counting the alignment inserted between the (aligned 4) array length and
the actual data.

Fix this properly and remove the exception for doubles.

https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-24 15:51:21 +02:00
Colin Walters
7009e317d8 gtlsinteraction: Hoist precondition before allocation
We're using a precondition in the middle of the function, and if we
hit it, we leak the closure.

Let's allocate the closure per path; this allows us to allocate it
before path-specific preconditions, and better avoids a pointless
malloc/free pair in the unhandled case.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 13:31:02 -04:00
Stef Walter
627b49b390 gio: Fix regression encoding an array of doubles
Take the simple slow path in this case. Encoding a double
takes special precautions as you can see in append_value_to_blob()
and friends.

https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-23 15:44:40 +02:00
Stef Walter
b6c1d696a9 gio: Add regression test for double array encoding
https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-23 15:44:40 +02:00
Colin Walters
91821974e1 gcredentials: Add assertion to pacify static analysis
This should always be true.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
8ebd287fe6 gkeyfilesettingsbackend: Add assertion for known-true condition
We know the group exists since we enumerated it.  Should silence a
static analysis warning.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
7ea4bf3f30 glocalfileinfo: Suppress static analysis return value warning
Just ignore the return value, since we're checking contents != NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
5fe71c7c5c gsettingsschema: Suppress return value check
We're intentionally ignoring the value here.  Pacifies static
analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
acdcf5cd50 gapplicationimpl-dbus: Fix leak of fd list object
Spotted by static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
3fb44c4c71 gsettingsschema: Close directory
Spotted by static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
e55a953642 gthreadedresolver: Unref unexpected address
I don't believe any real app would hit this, but we do leak
if it occurs.

Spotted by static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Colin Walters
feec280b7c gfile: Initialize variable to pacify static analysis
Not a real bug, but will quiet the analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Dan Winship
015db2d2af gio/tests/socket: add some missing g_assert_no_error()s 2014-07-21 11:31:27 -04:00
Dan Winship
634b692199 gsocket: Set SO_NOSIGPIPE on sockets on Darwin
This is a best-effort approach to preventing SIGPIPE emissions on Darwin
and iOS, where they continue to be intercepted by the Xcode debugger
even if SIG_IGN prevents them crashing the program.

This is similar to the existing code which sets MSG_NOSIGNAL on all
send() calls. MSG_NOSIGNAL doesn't exist on Darwin though.

Based on a patch from Philip Withnall.

https://bugzilla.gnome.org/show_bug.cgi?id=728730
2014-07-21 11:31:27 -04:00
Dan Winship
7b34e07ac4 gsocket: move set_fd_nonblocking() into g_socket_constructed() 2014-07-21 11:31:27 -04:00
Philip Withnall
ebe47823db ginetaddress: Add a precondition to g_inet_address_new_from_string()
Ensure that the input string is non-NULL, as inet_pton() does not like
NULL strings.

https://bugzilla.gnome.org/show_bug.cgi?id=733345
2014-07-18 08:50:18 +01:00
Ignacio Casal Quinteiro
641864bcba socketservice: minor cleanup 2014-07-17 13:30:50 +02:00
Marek Kasik
c7c4c3bf5e Remove redundant checks before free
Remove checks for NULL before g_free().

https://bugzilla.gnome.org/show_bug.cgi?id=733156
2014-07-14 16:02:35 +02:00
SyncEvolution Nightly Testing
f62c8fce8e gio: avoid g_object_ref(NULL) in g_dbus_object_manager_client_finalize
When establishing a D-Bus connection failed, g_dbus_object_manager_client_finalize()
calls g_object_ref(manager->priv->connection) when that pointer is NULL,
which is considered and logged as error by glib.

https://bugzilla.gnome.org/show_bug.cgi?id=732984
2014-07-14 08:35:11 -04:00
Matthias Clasen
b458d3da32 Fix a failing testcase
This fix is a bit of a blind guess, I couldn't really discern
from recent commits whether this is an expected behavior change
or not.
2014-07-14 08:27:30 -04:00
Michael Catanzaro
02c6e908d7 Fix typo 2014-07-09 10:49:39 -05:00
Ryan Lortie
5d0e295fb8 GDBusMessage: add some G_UNLIKELY on error paths
More for documentation than anything else...
2014-07-09 11:19:58 -04:00
Ryan Lortie
5463c8cedb GDBusMessage: fast-path decoding of fixed arrays
Instead of creating a separate GVariant for each of the 'y's in an 'ay',
use g_variant_new_fixed_array().

https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-09 10:43:26 -04:00
Ryan Lortie
958da1e9dc GDBusMessage: fast-path encoding of fixed arrays
Instead of handling each item separately, handle the array as a whole.

https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-09 10:43:26 -04:00
Dan Winship
f8d42cefbd gtask: fix leak in example code 2014-07-09 10:36:57 -04:00
Tristan Van Berkom
e608ec7b2e Added missing "Since:" annotations for g_input_stream_read_bytes() APIs. 2014-07-08 13:13:51 -03:00
Ryan Lortie
d108ada4b9 GDBusMessage: simplify byteswapping
Remove some duplication by simplifying our byteswap checks.

https://bugzilla.gnome.org/show_bug.cgi?id=732754
2014-07-07 15:02:54 -04:00
Ryan Lortie
5825055522 gapplication tests: test resource base path
Run some cases to make sure resource base path is behaving as we expect
it to.

https://bugzilla.gnome.org/show_bug.cgi?id=722092
2014-07-07 13:40:03 -04:00
Ryan Lortie
cea9de93c8 GApplication: add a "resource base path"
We don't use this for anything inside of GApplication yet, but Gtk is
about to start using it to find various bits of the application (such as
its menus, icons, etc.).

By default, we form the base path from the application ID to end up with
the familiar /org/example/app style.

https://bugzilla.gnome.org/show_bug.cgi?id=722092
2014-07-07 13:40:03 -04:00
Philip Withnall
60226a0386 ginetsocketaddress: Explicitly initialise flags for getaddrinfo()
This is not a functional change, as the hints field is static and hence
automatically initialised to zero — which happens to be what AF_UNSPEC
and the unspecified protocol are defined as. However, it’s best to be
explicit about this, in case AF_UNSPEC is _not_ defined as zero.

https://bugzilla.gnome.org/show_bug.cgi?id=732739
2014-07-06 12:56:41 +01:00
Sébastien Wilmet
48c7d041e2 doc: improve doc of g_input_stream_read()
I recently needed to nul-terminate the returned buffer, and I wasn't
sure if g_input_stream_read() does that or not. I've checked
glocalfileinputstream.c, which calls read(2) which doesn't nul-terminate
the buffer. So I assume it's the same behavior for all GInputStream
subclasses.

https://bugzilla.gnome.org/show_bug.cgi?id=732704
2014-07-04 17:03:50 +02:00
Sébastien Wilmet
b0c7221c55 doc: improve doc of g_subprocess_wait()
When using this API, I wasn't sure what the cancellable does. I think
it's generally desirable to kill the subprocess if the wait operation is
cancelled, since in this case the application is no longer interested by
the subprocess.

https://bugzilla.gnome.org/show_bug.cgi?id=732704
2014-07-03 20:11:46 +02:00
Michael Catanzaro
c3842d1969 Fix old wiki links 2014-07-01 23:52:19 -05:00
Sébastien Wilmet
ffe286e647 doc: improve doc of g_file_equal()
A critical message is printed when a parameter of g_file_equal() is not
a GFile. When we read the documentation before this commit, we can think
that passing NULL or another type than GFile is allowed, but it is not
the case.

Another option is to allow NULL parameters. But for consistency with
e.g. g_str_equal(), it's probably better to keep the code as is.

https://bugzilla.gnome.org/show_bug.cgi?id=732357
2014-06-29 17:57:24 +02:00
Sébastien Wilmet
82352ab8e7 doc: various improvements
- g_subprocess_launcher_spawn() and spawnv(): there is no other way
  AFAIK to create a GSubprocess from a launcher. So these
  functions are not "convenience helper".

- annotate optional arguments for g_shell_parse_argv().

- other trivial fix

https://bugzilla.gnome.org/show_bug.cgi?id=732357
2014-06-29 17:57:24 +02:00
Ryan Lortie
42e04f4eff GActionEntry: one more docs fix
Hyperlink "GVariant text format".
2014-06-29 11:34:16 -04:00
Ryan Lortie
c78037773b GActionEntry: improve documentation
Document that giving %NULL for the activate handler is supported since
GLib 2.40.  We documented this on GSimpleAction itself (where the
default handler functionality is implemented) but expecting the user to
dig that up is asking a bit much.

Also, add some more explicit documentation about the conditions under
which each field is expected to be filled in.

https://bugzilla.gnome.org/show_bug.cgi?id=732429
2014-06-29 11:14:45 -04:00
Koop Mast
1b3deb5f56 Change gio/data-to-c.pl to /usr/bin/env perl.
On FreeBSD perl gets installed in /usr/local, And a compat symlink in
/usr/bin. However this symlink might go away in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=724986
2014-06-28 14:06:59 -04:00
Patrick Welche
afce39c228 gcredentials: add NetBSD support
https://bugzilla.gnome.org/show_bug.cgi?id=728256
2014-06-28 14:06:36 -04:00
Lars Uebernickel
01098e34c1 GNotification: add priority
https://bugzilla.gnome.org/show_bug.cgi?id=731623
2014-06-28 14:05:23 -04:00
Ryan Lortie
59c9291f5f Revert "gsettings: remove long-deprecated "schema" property"
This reverts commit cf9b162e0d.

It turns out that there are still a very large number of users of this
API.

https://bugzilla.gnome.org/show_bug.cgi?id=732102
2014-06-24 16:57:12 -04:00
Ryan Lortie
cf9b162e0d gsettings: remove long-deprecated "schema" property
This property has been deprecated for three years after only having
existed for one.  We've wanted to reuse the name for all that time, so
let's try to actually remove it now and see if we can get away with it.

https://bugzilla.gnome.org/show_bug.cgi?id=732102
2014-06-24 14:18:28 -04:00
Ryan Lortie
f2ceb74e91 gsettings test: stop testing long-deprecated API
We want to try taking this away now...

https://bugzilla.gnome.org/show_bug.cgi?id=732102
2014-06-24 14:18:28 -04:00
Philip Withnall
f1095de46f gsocketlistener: Don’t explicitly close sockets on finalisation
Instead of closing the sockets explicitly, let them close themselves
when their final reference is dropped. This makes use of
g_socket_listener_add_socket() more natural.

https://bugzilla.gnome.org/show_bug.cgi?id=732107
2014-06-23 16:53:38 +01:00
Philip Withnall
00e733315d gsocket: Document that g_socket_create_source() holds a socket ref
This is quite important, as it means you can safely let the GSocket drop
out of scope while maintaining a reference to the GSource, and the
socket will remain open. That means fewer closure structures, simpler
code, and fewer allocations.

https://bugzilla.gnome.org/show_bug.cgi?id=732081
2014-06-23 16:24:47 +01:00
Matthias Clasen
90025254fd Return folder as icon for directories
'folder' is the name of the folder icon in the incon naming spec,
and the Adwaita icon theme doesn't include an inode-directory icon.
This fixes folders appearing as generic file in the file chooser.

https://bugzilla.gnome.org/show_bug.cgi?id=731996
2014-06-22 14:34:27 -04:00
Philip Withnall
d80adeaa96 gtestdbus: Don’t close stdout for dbus-daemon
The stdout FD passed to dbus-daemon is propagated to all its child
processes, such as service activated processes. If we close the FD after
reading the bus address from the daemon, any child process which
subsequently writes to stdout (e.g. for logging) will get a SIGPIPE and
explode.

Instead of closing the stdout FD immediately after dbus-daemon has
spawned, keep it open until the daemon is killed.

https://bugzilla.gnome.org/show_bug.cgi?id=732019
2014-06-22 13:02:18 +01:00
Tim-Philipp Müller
94e13c71c5 gio/tests/socket: fix minor memleak 2014-06-13 19:32:09 +01:00
Daniel Macks
b413f7a285 gnextstepsettingsbackend: Use same token for function-call and its availability
Availability of the g_nextstep_settings_backend_get_type() prototype
is controlled by HAVE_COCOA in gsettingsbackendinternal.h and the
actual implemenation by OS_COCOA in Makefile.am. Therefore, the
giomodule.c call to that function should also be protected by a COCOA
token rather than an CARBON token (cocoa and carbon are independent
autoconf tests).

https://bugzilla.gnome.org/show_bug.cgi?id=731425
2014-06-10 09:24:43 -04:00
Matthias Clasen
dc496ac764 Add a test for GMenuAttributeIter 2014-06-05 08:04:47 -04:00
Matthias Clasen
90671cd3cd docs: Add missing language annotations 2014-06-01 09:38:49 -04:00
Matthias Clasen
a484719033 docs: Fix up varargs documentation
gtk-doc expects varargs to be documented in a specific way,
otherwise it complains.
2014-05-31 10:54:02 -04:00
Dan Winship
84fd73b2fa gio/tests/network-address: fix when no network is available
GResolver doesn't do full validation of its inputs, so in some of
these tests, the fact that we were getting back
G_RESOLVER_ERROR_NOT_FOUND is because the junk string was getting
passed to an upstream DNS resolver, which returned NXDOMAIN. But if
there's no network on the machine then we'd get
G_RESOLVER_ERROR_INTERNAL instead in that case.
2014-05-27 09:42:50 -04:00
Ryan Lortie
6f7dc3a44f gio tests: rm xdgconfighome on 'make clean' 2014-05-26 23:01:56 +02:00
Evan Nemerson
570b27b9ac gio: port annotations from the Vala metadata.
https://bugzilla.gnome.org/show_bug.cgi?id=730493
2014-05-23 10:04:06 -07:00
Murray Cumming
2a27b72522 GDBusError enum: Remove trailing comma.
This is helpful to people using the g++ --pedantic option.
2014-05-22 12:46:07 +02:00
Philip Withnall
cdb9670dc3 gdbus-tool: Remove dead variables
Coverity issues: #1159447, #1159446

https://bugzilla.gnome.org/show_bug.cgi?id=730295
2014-05-20 11:03:02 +01:00
Philip Withnall
e1243d11f0 gsubprocess: Add a missing va_end() call
Coverity issues: #1214070, #1214069

https://bugzilla.gnome.org/show_bug.cgi?id=730278
2014-05-20 11:01:37 +01:00
Philip Withnall
7f5cc2c3c5 gsocket: Add missing preconditions to g_socket_send_message()
https://bugzilla.gnome.org/show_bug.cgi?id=730190
2014-05-15 14:35:19 +01:00
Philip Withnall
60e459b196 gresource-tool: Fix an FD leak in an error path
Coverity issues: #1214054, #1214055, #1214056
2014-05-15 14:35:19 +01:00
Chun-wei Fan
c2a828772b gio/gtestdbus.c: Fix write_config_file() for Windows
Windows does not like g_unlink() to be called on files whose file
descriptor is still open, so doing that would cause a permission
denied error.  Since the fd is not used in that function after
acquiring the temp file, close it earlier before
g_file_set_contents(), so that it can complete successfully.

This fixes a number of GTK+ tests on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=719344
2014-05-12 22:14:05 +08:00
Sébastien Wilmet
430e6fd6ad doc: various improvements
- GSubprocessLauncher exists since 2.40, not 2.36
- more logical order for g_markup functions
- fix short description of GMarkup
- GMarkupParser: specify that some parameters are NULL-terminated.
- g_string_new (NULL); is possible.
- other trivial fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=728983
2014-05-09 18:47:42 +02:00
Lukasz Skalski
7c205ae90d gio: cleanup gdbusmessage.c file
* removed passing GError to ensure_input_padding() function
  - it was necessary before commit 3e5214c15c
  when we used GData*Streams and GMemoryInputStream with
  g_seekable_seek() - now it's useless,

* removed checking return value of ensure_input_padding()
  function - in previous implementation (like above)
  g_seekable_seek() could return FALSE - now it's always TRUE,

* removed passing GError to g_memory_buffer_read_*() functions
  and checking returned value - it also has been inherited after
  old implementation with g_data_input_stream_read_*() functions
  - now it's also useless

* cleaned up code formatting,

https://bugzilla.gnome.org/show_bug.cgi?id=729875
2014-05-09 10:21:22 -04:00
Ryan Lortie
079d20f012 tests: add testcase for {Only,Not}ShowIn
https://bugzilla.gnome.org/show_bug.cgi?id=729813
2014-05-08 16:19:56 -04:00
Ryan Lortie
5a5e16e93c AppInfo: use XDG_CURRENT_DESKTOP for OnlyShowIn
Expand the functionality of g_desktop_app_info_set_desktop_env() to
include the possibility of passing strings containing ':' characters (as
some apps, such as gnome-session, are directly passing the value of
XDG_CURRENT_DESKTOP).  At the same time, deprecate it, since now we get
the list from the environment variable for ourselves.

Modify the checks in g_desktop_app_info_get_show_in() to deal with
multiple items listed in XDG_CURRENT_DESKTOP.  For example, if we find
that we have

  XDG_CURRENT_DESKTOP=GNOME-Classic:GNOME

and a desktop file contains:

  OnlyShowIn=GNOME

then we will show this file because of the fallback to GNOME.  If the
file _also_ contains the line:

  NotShowIn=GNOME-Classic

Then we will not show it, because GNOME-Classic comes before GNOME in
XDG_CURRENT_DESKTOP.

https://bugzilla.gnome.org/show_bug.cgi?id=729813
2014-05-08 16:19:56 -04:00
Ryan Lortie
880e8e8cb2 tests: add tests for GDesktopAppInfo Implements=
https://bugzilla.gnome.org/show_bug.cgi?id=712391
2014-05-08 16:19:55 -04:00
Ryan Lortie
9aaf990960 Add g_desktop_app_info_get_implementations()
This provides support for the draft addition of 'Implements=' to the Desktop
Entry specification.

https://bugzilla.gnome.org/show_bug.cgi?id=712391
2014-05-08 16:19:05 -04:00
Lionel Landwerlin
1565a49144 gio: iostream: use GTask instead of internal pointer
This fixes an infinite recursion loop when calling
g_io_stream_close_async() on a SoupIOStream.

https://bugzilla.gnome.org/show_bug.cgi?id=722723
2014-05-05 11:10:09 -04:00
Dan Winship
81e0a2f362 gio: add a missing property to GDummyTlsConnection
GDummyTlsConnection didn't implement the "interaction" property,
meaning you'd get warnings if you tried to set it while creating a
GTlsConnection when using the dummy backend. (Of course, trying to
create the GTlsConnection will fail anyway, but it ought to fail
without hitting any g_warnings.)
2014-05-03 17:27:44 -04:00
Lars Uebernickel
4ba23522b1 gmenuexporter: fix protocol documentation link 2014-04-28 09:28:21 +02:00
Juan Pablo Ugarte
254b8dfcd0 Added type check to GPermission public functions. 2014-04-25 20:06:41 -03:00
Philip Withnall
956921e51f gresolver: Ensure GThreadedResolver always sets an error if resolution fails
It was previously possible for GThreadedResolver to return an empty list
and no error in response to a g_resolver_lookup_by_name() call, if it
happened that all the addresses returned by getaddrinfo() could not be
converted from native addresses to GSocketAddresses.

Fix that by setting a G_RESOLVER_ERROR_NOT_FOUND if the returned list is
empty.

https://bugzilla.gnome.org/show_bug.cgi?id=728776
2014-04-25 09:52:01 +01:00
Philip Withnall
14b0c15abb gresolver: Document that GResolver lists are non-empty on success
The documentation previously wasn’t clear about whether the GResolver
methods could return an empty list and no error. On balance, this seems
like a bad idea, and GResolver should commit to always return a
non-empty list, or an error (which should be G_RESOLVER_ERROR_NOT_FOUND
if the list would otherwise be empty).

https://bugzilla.gnome.org/show_bug.cgi?id=728776
2014-04-25 09:52:01 +01:00
Dan Winship
c565d645e9 gio: remove an unneeded pragma
ddf82a25 removed the use of non-literal format strings from
gthreadedresolver.c, but left the "#pragma GCC diagnostic ignored
-Wformat-nonliteral" behind.
2014-04-24 12:18:36 -04:00
Volker Sobek
4441595378 docs: Remove <!-- --> comment before plural s
These did show up in the html. Since symbol names are checked for a
trailing plural s when generating the docs, the links stay functional
after removing these comments.

https://bugzilla.gnome.org/show_bug.cgi?id=728380
2014-04-24 13:42:37 +02:00
Philip Withnall
99b67614b7 gaction: Minor clarifications in the GAction documentation
https://bugzilla.gnome.org/show_bug.cgi?id=728350
2014-04-23 13:02:41 +01:00
Philip Withnall
9352cdb5f4 gfile: More explicitly document the context for GFileProgressCallback
Be more explicit in the documentation for g_file_copy_async() about
which GMainContext its progress callback is executed in.

https://bugzilla.gnome.org/show_bug.cgi?id=728565
2014-04-19 18:24:04 +01:00
Philip Withnall
2b247e1589 gio: Document that GSocket is not thread safe
https://bugzilla.gnome.org/show_bug.cgi?id=726318
2014-04-16 19:04:25 +01:00
Volker Sobek
9f0ad54c80 docs: Use markdown links in all .c and .h files
Commit e7fd3de86d already did most of this.

https://bugzilla.gnome.org/show_bug.cgi?id=728285
2014-04-15 22:19:07 +02:00
Ryan Lortie
afaee8dc6a gdesktopappinfo: fix a crasher
During the time that we are expanding the strv, it is not
null-terminated.  Use the strv_len variable instead to bound the search
for duplicates.
2014-04-15 14:12:58 -04:00
Alberto Ruiz
7916f6d636 gio: fix g-i annotations in g_settings_schema_source_list_schemas() 2014-04-15 18:56:26 +02:00
Ryan Lortie
9a5e85c078 tests: use mimeapps.list over defaults.list
defaults.list is deprecated, so use mimeapps.list as a filename instead.

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:39 -04:00
Ryan Lortie
6fd5a8cdaa GDesktopAppInfo: rewrite content type code
Redo the code for type-based selection of applications (all,
recommended, default, fallback) based on the new DesktopFileDir
structures that we introduced last cycle.

At the same time, we expand the functionality to add support for the new
features of the specification:

 - moving ~/.local/share/applications/mimeapps.list to ~/.config/

 - per-desktop default applications (via XDG_CURRENT_DESKTOP)

 - sysadmin customisation of defaults (via /etc/xdg/mimeapps.list)

 - deprecation of the old defaults.list, favouring the use of
   /usr/share/applications/mimeapps.list (or gnome-mimeapps.list) to
   accomplish the same

We modify the mimeapps testcase to check for mimeapps.list having been
created in XDG_CONFIG_HOME instead of XDG_DATA_HOME.

The modification is a net reduction of code (due to less duplication in
bookkeeping).  It is also an increase in performance and reduction in
memory consumption (due to simplified data structures).  Finally, it
removes the stat-based timestamp checking in favour of the
GFileMonitor-based approach that was already being used in the
implementation of DesktopFileDir (in order to know if we had to rescan
the desktop files themselves).

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:39 -04:00
Ryan Lortie
caf0f1df1c mimetype tests: don't depend on specific behaviour
We currently assume that setting an application as the default will take
it to the front of the list of supported applications for a given type,
but this is not necessarily true.

Check instead that the application is actually set as default.

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:39 -04:00
Ryan Lortie
54047080e9 appmonitor test: avoid /usr/share
Set XDG_DATA_DIRS to make sure we don't use /usr/share from the
appmonitor test.  We will soon throw a warning if we find defaults.list,
so make sure we don't open ourselves up to that if there is one on the
system.

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:39 -04:00
Ryan Lortie
a366b6f2d5 tests: expand 'apps' tool
Add modes to output the applications found for get_default_,
get_recommended_, get_fallback_ and get_all_for_type().

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:38 -04:00
Ryan Lortie
41761a134d mimeapps test: fix defaults vs. recommended
The desktop file for myapp3 didn't declare support for image/png, but
the testcase expects it to be recommended on the basis of it being the
default app according to defaults.list.

This will not work in the future -- we will only list apps that actually
support the filetype in question, unless they've been explicitly added
as associations.

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:38 -04:00
Ryan Lortie
84e9829fee desktop-app-info test: use g_assert_strcmp()
Replace some assert(strcmp()) with g_assert_strcmp() so that we get
better output in case of failures.

https://bugzilla.gnome.org/show_bug.cgi?id=728040
2014-04-15 11:36:38 -04:00
Colin Walters
2d96503898 gdesktopappinfo: Don't double free sn_id
Not sure why mclasen added a g_free() in that path, it was just wrong.
We free it correctly later.
2014-04-12 13:26:29 -04:00
Colin Walters
af1772b642 gdesktopappinfo: Initialize sn_id to NULL
Otherwise we'll be freeing a random stack pointer.
2014-04-12 13:21:20 -04:00
Matthias Clasen
94e5dafbc9 Deal with startup notify id being NULL
The app launch context may just not support startup notification,
in which case, g_app_launch_context_get_startup_notify_id() will
return NULL.

Failure to take this into account leads to criticals like this:
gnome-session[8489]: GLib-CRITICAL: g_variant_new_take_string: assertion 'string != NULL' failed
gnome-session[8489]: GLib-CRITICAL: g_variant_new_variant: assertion 'value != NULL' failed
gnome-session[8489]: GLib-CRITICAL: g_variant_get_type: assertion 'value != NULL' failed
gnome-session[8489]: GLib-CRITICAL: g_variant_type_is_subtype_of: assertion 'g_variant_type_check (type)' failed

https://bugzilla.gnome.org/show_bug.cgi?id=728066
2014-04-11 19:00:12 -07:00