Commit Graph

5389 Commits

Author SHA1 Message Date
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
Cosimo Cecchi
9fe9a676a4 gapplication-tool: ensure object paths are valid
Hyphens are not valid characters for DBus object paths; see the similar
code in gapplicationimpl-dbus.c

https://bugzilla.gnome.org/show_bug.cgi?id=727928
2014-04-10 09:16:22 -07:00
Cosimo Cecchi
59d11879ef gapplication-tool: fix a typo
This must have never worked.

https://bugzilla.gnome.org/show_bug.cgi?id=727928
2014-04-10 09:16:22 -07:00
Debarshi Ray
0e44b29340 giomodule: Add a NULL guard to extension_point_get_extension_by_name
... otherwise a NULL input will lead to a crash in strcmp.

https://bugzilla.gnome.org/show_bug.cgi?id=727964
2014-04-10 15:27:16 +02:00
Colin Walters
7089cf8967 g_file_copy: Don't set GError when we intend to ignore errors
For better or worse, the current g_file_copy intention was to ignore
errors copying metadata, but we still set the GError, while returning
TRUE.

https://bugzilla.gnome.org/show_bug.cgi?id=727559
2014-04-09 20:22:38 -04:00
Stef Walter
76d6fd01de gio: Add newer dbus UnknownXxxx and PropertyReadOnly errors
Add G_DBUS_ERROR codes for:

 * org.freedesktop.DBus.Error.UnknownObject
 * org.freedesktop.DBus.Error.UnknownInterface
 * org.freedesktop.DBus.Error.UnknownProperty
 * org.freedesktop.DBus.Error.PropertyReadOnly

These were discussed on the dbus mailing list
and introduced in the following libdbus commit:

2c34514620c4b79ea4ec71d1db583379138d01ac

https://bugzilla.gnome.org/show_bug.cgi?id=727900
2014-04-09 20:48:19 +02:00
Dan Winship
65f2669173 gtlscertificate: fix certificate list parsing with trailing comments
g_tls_certificate_list_new_from_file() was supposed to ignore non-PEM
content, but it accidentally required that there not be anything after
the last certificate. Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=727692
2014-04-09 10:39:45 -04:00
Marek Kasik
b81c12fcab GApplication: Don't decrease use_count below 0
Place an assert for use_count to be at least 1
in g_application_release() so we don't decrease
it below 0.

https://bugzilla.gnome.org/show_bug.cgi?id=727551
2014-04-04 16:04:46 +02:00
Wim Taymans
20feb23569 networkaddress: fix parsing of uri with @ after authority
Make sure that the @ sign is inside the authority part before attempting
to parse the userinfo. We do this by checking if the @ sign comes before
any of the possible authority delimiters.
Add unit test to verify parsing of ftp://ftp.gnome.org/start?foo=bar@baz

https://bugzilla.gnome.org/show_bug.cgi?id=726040
2014-04-02 11:23:29 -04:00
Olivier Crête
638993f5ac networkmonitornetlink: IN6_IS_ADDR_MC_LINKLOCAL is only guaranteed to work on struct in6_addr*
https://bugzilla.gnome.org/show_bug.cgi?id=727119
2014-03-31 12:48:04 -04:00
Dan Winship
3da5d59078 gio: move Winsock error mapping to g_io_error_from_win32_error()
Rather than having special code in gsocket.c, handle Winsock errors
along with other Win32 errors in gioerror.c

Also, reference g_win32_error_message() from the
g_io_error_from_win32_error() docs, and update the
g_win32_error_message() docs to clarify that it works with Winsock
error codes too.
2014-03-30 11:55:47 -04:00
Dan Winship
befc111c43 gio/tests/socket: Update to check the error code
Only treat IPv6 as unsupported if the attempt to create a socket
returns G_IO_ERROR_NOT_SUPPORTED: any other error is a bug.
2014-03-30 11:06:35 -04:00
Dan Winship
9fc35dbfb6 gioerror: map some more values to G_IO_ERROR_NOT_SUPPORTED
Map EPROTONOSUPPORT, ESOCKTNOSUPPORT, EPFNOSUPPORT and EAFNOSUPPORT to
G_IO_ERROR_NOT_SUPPORTED in g_io_error_from_errno(). (GSocket's
socket_io_error_from_errno() already did this with the corresponding
Winsock errors.)

Also map EOPNOTSUPP, which on Linux is the same as ENOTSUP, but may
not be on other platforms.

Also, rewrite the EAGAIN/EWOULDBLOCK section to use the simpler idiom
used by EEXIST/ENOTEMPTY and (now) ENOTSUP/EOPNOTSUPP.
2014-03-30 11:06:35 -04:00
Volker Sobek
a0b932ac8b docs: Remove escaping '\' from literals
commit 35066ed6c6 replaced entities, but
escaped the replacement text also inside literals, which resulted in the
escaping '\' to also appear in the documentation.

https://bugzilla.gnome.org/show_bug.cgi?id=727320
2014-03-30 08:37:23 -04:00
Bastien Nocera
8792609e15 gio: Add names to idles and timeouts
This isn't too useful for some of the "return result in idle"
functions, but it's better than nothing.

https://bugzilla.gnome.org/show_bug.cgi?id=726872
2014-03-27 12:53:00 +01:00
Volker Sobek
e1dee398bf GNotification: Some small documentation fixes
Use #GVariant instead of GVariant.

g_notification_add_button_with_target,
g_notification_set_default_action_and_target:
Replace 'format_string' with 'target_format'.

g_notification_set_default_action_and_target_value:
Remove paragraph that apparently had been accidentally copied from
g_notification_set_default_action_and_target.

https://bugzilla.gnome.org/show_bug.cgi?id=727123
2014-03-27 01:04:12 +01:00
Olivier Crête
0c65f7e45a GSocket: ignore timed out state when not relevant
Do this by separating the timeout check from the other socket checks.

https://bugzilla.gnome.org/show_bug.cgi?id=726375
2014-03-23 16:17:09 -04:00
Dan Winship
1e8c4d2a6e gio: fix two more g_task_return_error_if_cancelled() leaks
https://bugzilla.gnome.org/show_bug.cgi?id=726611
2014-03-23 15:00:03 -04:00
Olivier Crête
14872d2929 socketclient: Fix leak
https://bugzilla.gnome.org/show_bug.cgi?id=726611
2014-03-23 15:00:03 -04:00
Dan Winship
98aa80b262 gio/tests/socket: skip IPv6 tests on IPv6-less machines
https://bugzilla.gnome.org/show_bug.cgi?id=667468
2014-03-21 09:36:52 -04:00
Dan Winship
c67d23aa2f Clarify expectations with error codes like G_IO_ERROR_FAILED
If an error code enumeration is expected to be extended in the future,
people shouldn't compare explicitly against its generic "FAILED" value.

https://bugzilla.gnome.org/show_bug.cgi?id=726775
2014-03-20 09:31:56 -04:00
Ryan Lortie
3f119b2fd4 GSettingsBackend: fix a nasty race condition
In the event that a GSettings object is being destroyed just as a change
signal is being delivered, the destroying thread will race with the
dconf worker thread for acquiring the lock on the GSettingsBackend.

If the signalling thread gets there first then the destroying thread
will block on the lock.  The signalling thread adds a reference to the
GSettings object that is being destroyed and releases the lock.  The
idea is that this should prevent the GSettings object from being
destroyed and thus maintain its entry in the list.  Unfortunately, the
weak reference notify function is already running and as soon as we
release the lock, the list entry is removed.

The signalling thread crashes.

This bug is indicative of a serious problem encountered in many
situations where GObject instances are touched from multiple threads.
Ideally, we will move to a place where g_object_ref() is not called at
all on the GSettings object from the dconf worker thread and instead, a
dispatch will be done without holding a reference (similar to how
GAppInfoMonitor presently works).  This would also prevent the
unfortunate case of someone dropping what they assume to be the last
reference on a GSettings object, only to have an already-pending signal
delivered once they return to the mainloop, crashing their program.

Making this change for GSettings (with multiple instances per thread,
the possibility of multiple backends and each instance being interested
in different events) is going to be extremely non-trivial, so it's not a
change that makes sense at this point in the cycle.

For now, we can do a relatively small and isolated tweak so that we
never access the list except under a lock.  We still perform the bad
pattern of acquiring a ref in a foreign thread which means that we still
risk delivering a signal to a GSettings object that the user has assumed
is dead (unless they explicitly disconnect their signal handler).  This
is a problem that we already had, however.

https://bugzilla.gnome.org/show_bug.cgi?id=710367
2014-03-14 09:46:39 -04:00
Ryan Lortie
698970f1f7 gsettingsbackend: a minor simplification
Change the order of the arguments on the (internal) keys_changed callback in
GSettingsListenerVTable.

This means that all functions in the table now fit the following signature:

  void (* f) (GObject             *target,
              GSettingsBackend    *backend,
              const gchar         *name_or_path,
              gpointer             origin_tag,
              const gchar * const *names);

allowing the possibility of arguments ignored at the end.

This allows us to simplify our dispatch-to-thread code in GSettingsBackend,
making it a bit less generic.

So far, this should be a straight refactor.

https://bugzilla.gnome.org/show_bug.cgi?id=710367
2014-03-14 09:46:39 -04:00
Ryan Lortie
ffe4e94e3a GUnixVolume: implement _finish functions
The _finish functions for GUnixVolume _mount and _eject functions were
never implemented, having been simply stubbed out as 'return TRUE;'.

Implement them.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
2014-03-11 21:28:58 -04:00
Ryan Lortie
62fa9c578f GUnixVolume: port to GSubprocess
Do the same as we just did for GUnixMount, for GUnixVolume too.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
2014-03-11 21:28:58 -04:00
Ryan Lortie
64ec757d05 GUnixMount: port unmount to GSubprocess
The existing code is buggy and now that we have GSubprocess, we should just use
it instead, allowing for some substantial reduction in complexity.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
2014-03-11 21:28:58 -04:00
Lars Uebernickel
8c78fb827b glocalfileinfo: don't special-case directory icons
As of e6af432, g_content_type_get_symbolic_icon() returns non-symbolic
fallbacks. Thus, we can't append another symbolic icon to the fallbacks.

The special case was a bit of a hack anyway. It was only applied to
themed icons and there was no generic fallback for mime types that are
not folders.

https://bugzilla.gnome.org/show_bug.cgi?id=726046
2014-03-11 11:47:57 +01:00
Ryan Lortie
66e2ffe978 gio tests: add codegen to BUILT_SOURCES
We need to have these in BUILT_SOURCES so that 'make' knows to generate them
before attempting to compile other .c files in the same directory (since some
of these files include the header).

Should fix up remaining issues about partial versions of this file being
included under parallel builds.

https://bugzilla.gnome.org/show_bug.cgi?id=725891
2014-03-07 07:47:14 -05:00
Matthias Clasen
fd8c1a3067 Work around gtk-doc problems
Returns shall never be at the beginning of a line.
2014-03-04 20:20:52 -05:00
Ryan Lortie
2b11af4f1f gsubprocess: test environment a bit more
Add a test for GSubprocess to test setting, unsetting and inheritance of
environment variables.  Use communicate() to give it a bit more of a
workout as well.

https://bugzilla.gnome.org/show_bug.cgi?id=725651
2014-03-04 09:08:24 -05:00
Ryan Lortie
e767204e0e GSubprocessLauncher: don't get empty environment
Use g_get_environ() to get the environment variables with their values
instead of g_listenv() which only lists off the keys.

https://bugzilla.gnome.org/show_bug.cgi?id=725651
2014-03-04 08:55:00 -05:00
Ryan Lortie
9da88a12c5 gsubprocess: test empty splices
Make sure we handle the case that our splice returns no data properly.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
2014-03-03 21:26:24 -05:00
Ryan Lortie
9f71965bec gsubprocess: fix communicate() with empty buffers
On the splice for stdout or stderr completing, GSubprocess calls
_slice_finish() to collect the result.

We assume that a zero return value here means failure, but in fact this
function returns a gssize -- the number of bytes transferred, or -1 for
an error.

This causes GSubprocess to mistakenly think that it has an error when it
actually just has an empty buffer (as would be the case when collecting
stderr from a successful command).

Check for -1 instead of FALSE to detect the error.

https://bugzilla.gnome.org/show_bug.cgi?id=724916
2014-03-03 21:26:24 -05:00
Ryan Lortie
5d5ea495b5 desktopappinfo: add Exec to searchable keys
Add the basename from the first component of the Exec line to the list of
strings to search for via g_desktop_app_info_search().

We treat Exec as a fairly strong match -- just below the visible name.

Add a testcase to make sure everything is working OK.

https://bugzilla.gnome.org/show_bug.cgi?id=725023
2014-03-03 16:01:27 -05:00
Matthias Clasen
49cc207e35 docs: Ditch more markup
Some markup was hiding in docs in headers. Drop it there, too.
2014-03-02 18:23:43 -05:00
Matthias Clasen
e7bde4acf4 Test content type icons more thoroughly
Check we actually get the right icon names, and check
that symbolic icons fall back to non-symbolic ones.
2014-02-23 12:11:59 -05:00
John Lindgren
e6af432b39 Add non-symbolic fallback icons in g_content_type_get_symbolic_icon().
This makes the behavior consistent with e.g. g_volume_get_symbolic_icon().

https://bugzilla.gnome.org/show_bug.cgi?id=724994
2014-02-23 12:11:59 -05:00
Chun-wei Fan
4825e819b2 Fix build of gio/gapplication.c on Visual C++
Visual C++ is quite zealous about checking against the types used in the
initializing of array of structures, even up to Visual C++ 2013.  Fix this
by splitting up the initializing steps.

https://bugzilla.gnome.org/show_bug.cgi?id=724609
2014-02-23 11:48:06 +08:00
Ryan Lortie
8da795de4f gsocket: use check/prepare only on win32
There is no longer any code left in the check/prepare functions on UNIX,
so put %NULL in the GSourceFuncs vtable.

This also allows us to simplify some logic.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
e8f26efe0d gsocket: use _add_unix_fd() instead of _add_poll()
Use g_source_add_unix_fd() on UNIX instead of using a GPollFD.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
04aee2d920 gsocket: make use of g_source_set_ready_time()
Drop our own hand-rolled version of the same functionality.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:25:42 -05:00
Ryan Lortie
1f7100506a gsocket: don't abuse GPollFD.revents field
We are reusing the GPollFD.revents field of the source to store a
temporary value.  Use a local variable for that instead.

This is a refactor to make the next commit easier to understand.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
Ryan Lortie
ff96f88e17 gsocket: use cancellable child source
Now that GCancellable's GSource is based on _set_ready_time() instead of
an fd, we should use it as a child source, instead of forcing the
creation of the fd and adding it as a poll.

https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
Ryan Lortie
d8263dd793 gsocket: trivial typo fix
https://bugzilla.gnome.org/show_bug.cgi?id=724707
2014-02-22 10:24:19 -05:00
William Jon McCann
20f4d1820b docs: use "Returns:" consistently
Instead of "Return value:".
2014-02-19 19:41:52 -05:00
Chun-wei Fan
9cb53851be gio/gresolver.c: Fix build on Windows
Windows does not come with inet_aton(), and this check on IPv4 addresses
is actually not needed on Windows as the getaddrinfo() implementation on
Windows already rejects non-standard and non-real IPv4 numbers-and-dots
addresses.

https://bugzilla.gnome.org/show_bug.cgi?id=724609
2014-02-20 08:36:54 +08:00
Ryan Lortie
c37cd19fee Work around test failure in gdbus-names
This is caused by g_test_dbus_down() returning too soon.

Add a sleep for now.

https://bugzilla.gnome.org/show_bug.cgi?id=711807
2014-02-17 18:18:20 -05:00
Ryan Lortie
53d5b17f62 GApplication: disable some more tests
Disable some racy GApplication testcases.  We need some better non-hacky
GApplication tests...

https://bugzilla.gnome.org/show_bug.cgi?id=724126
2014-02-17 17:44:58 -05:00
Dan Winship
4139b26f3e gsocket: fix g_socket_condition_timed_wait() recovery after EINTR
After getting an EINTR, g_socket_condition_timed_wait() has to adjust
its timeout, but it was trying to convert from nanoseconds to
microseconds by multiplying by 1000 rather than dividing... Oops.

https://bugzilla.gnome.org/show_bug.cgi?id=724239
2014-02-17 11:38:11 -05:00
Ross Burton
299ca6dc1e gio/tests: fix race when generating code
There is a race condition in the makefile that can result in build failures like this in parallel builds:

| ./gdbus-test-codegen-generated.h:7:0: error: unterminated #ifndef
|  #ifndef __GDBUS_TEST_CODEGEN_GENERATED_H__

This is because a rule like this:

x.c x.h: prerequisites
	@commands

doesn't consider x.c and x.h together. Instead, it expands to two rules, one to
generate x.c and one to generate x.h, which happen to run the same commands.  In
the worst case they execute in parallel, overwriting each other's output.

Signed-off-by: Ross Burton <ross.burton@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723616
2014-02-17 10:21:31 +00:00
Olivier Crête
ed017994c9 subprocess: Init and clear the mutex
Fixes the leak of the GMutexImpl allocated inside the first call to g_mutex_lock()
on an uninitialized GMutex.

https://bugzilla.gnome.org/show_bug.cgi?id=724401
2014-02-16 19:59:44 -05:00
Paolo Borelli
a732f2966d Annotate g_application_add_main_option_entries 2014-02-16 22:06:11 +01:00
Dan Winship
8902276101 g_simple_async_result_is_valid: fix for NULL source tag
If a GSimpleAsyncResult has a NULL source tag, allow it to compare
valid to a non-NULL source tag in g_simple_async_result_is_valid(), to
simplify cases where, eg, g_simple_async_result_new() and
g_simple_async_result_report_error_in_idle() are both used.

https://bugzilla.gnome.org/show_bug.cgi?id=721458
2014-02-16 09:24:04 -05:00
Koop Mast
9c135707cb Fix the build on FreeBSD by replacing EAI_NODATA with EAI_NONAME.
https://bugzilla.gnome.org/show_bug.cgi?id=724434
2014-02-15 18:35:57 -05:00
Ryan Lortie
7cbff954b9 win32: fixup lib.exe invocation
We have a configure.ac check for lib.exe that attempts to enable
creation of .lib files for our 5 public libraries.  That has been broken
for a long time for two reasons:

 1) the Makefiles hardcode 'lib' instead of 'lib.exe'

 2) we dropped generation of .def files quite some time ago (except for
    in gthread where we have the two-symbol file under version control)

Add new rules for creating .def files from dumpbin.exe (which you should
have if you have lib.exe) and fix the .lib rules to use lib.exe.

Add a bit of $(AM_V_GEN) all around, as well.

https://bugzilla.gnome.org/show_bug.cgi?id=722033
2014-02-15 16:55:25 -05:00
Dan Winship
5575a3e9cb gio: don't accept nonstandard IPv4 "numbers-and-dots" addresses
In addition to the standard "192.168.1.1" format, there are numerous
legacy IPv4 address formats (such as "192.168.257",
"0xc0.0xa8.0x01.0x01", "0300.0250.0001.0001", "3232235777", and
"0xc0a80101"). However, none of these forms are ever used any more
except in phishing attempts. GLib wasn't supposed to be accepting
these addresses (neither g_hostname_is_ip_address() nor
g_inet_address_new_from_string() recognizes them), but getaddrinfo()
accepts them, and so the parts of gio that use getaddrinfo()
accidentally did accept those formats.

Fix GNetworkAddress and GResolver to reject these address formats.

https://bugzilla.gnome.org/show_bug.cgi?id=679957
2014-02-15 10:22:24 -05:00
Dan Winship
074df39681 Fix g_socket_get_available() with TCP on Windows
Windows needs a special inefficient hack to implement
g_socket_get_available() correctly for UDP sockets, but that hack
isn't needed for TCP, and in fact, might give the wrong answer in that
case. Fix it to only use the hack with UDP.

Also, fix that case to handle non-blocking sockets as well.

And add a test case for g_socket_get_available() with TCP.

https://bugzilla.gnome.org/show_bug.cgi?id=723422
2014-02-15 10:06:04 -05:00
Matthias Clasen
bc6ee788b4 docs: let go of &ast;
Since we are no longer using sgml mode, using /&ast; &ast;/ to
escape block comments inside examples does not work anymore.
Switch to using line comments with //
2014-02-14 21:33:36 -05:00
Ryan Lortie
450e7b1036 configure.ac: tweak inotify check
Our check for inotify_init1() being defined is broken.  We happily
declare that inotify is supported, even if the check fails.

This was originally intended to check for inotify_init1 in the libc so
that we could fall back to inotify_init if it was not yet defined.

FreeBSD has a libinotify that emulates the inotify API via kqueue.  It
installs a <sys/inotify.h> header and requires linking to -linotify.  We
don't want to falsely detect working inotify in this case.

Treat the lack of inotify_init1() in the libc as a lack of inotify
support.  This requires only a new libc -- we still support old kernels:
in the case that inotify1_init() fails, we fall back to inotify_init().

https://bugzilla.gnome.org/show_bug.cgi?id=724330
2014-02-14 10:42:40 -05:00
Dan Winship
db83b8ac4c gtask: fix trivial doc typo 2014-02-13 12:59:29 -05:00
Philip Withnall
169846c5ab gsocketconnection: Document closing connections with g_io_stream_close()
It’s not enough to close a connection by calling g_input_stream_close()
and g_output_stream_close() on its two substreams: to close the
underlying socket, one must use g_io_stream_close(). Document that.

https://bugzilla.gnome.org/show_bug.cgi?id=724278
2014-02-13 14:09:48 +00:00
Dan Winship
0017728c8c gsocketservice: Clarify g_socket_service_stop() documentation
https://bugzilla.gnome.org/show_bug.cgi?id=724233
2014-02-13 08:30:59 -05:00
Philip Withnall
d173d97c9b gsubprocess: Fix ‘Since’ lines in documentation to read 2.40
GSubprocess was introduced in GLib 2.40, not 2.36.

https://bugzilla.gnome.org/show_bug.cgi?id=724001
2014-02-10 08:50:36 +00:00
Philip Withnall
24536dd030 gsubprocess: Fix a broken link in the documentation
https://bugzilla.gnome.org/show_bug.cgi?id=724001
2014-02-10 08:22:30 +00:00
Matthias Clasen
35066ed6c6 Docs: Drop entities, switch away from sgml mode
Since all element markup is now gone from the doc comments,
we can turn off the gtk-doc sgml mode, which means that from
now on, docbook markup is no longer allowed in doc comments.

To make this possible, we have to replace all remaining
entities in doc comments by their replacement text, &amp; -> &
and so on.
2014-02-09 02:07:26 -05:00
Matthias Clasen
a03cee3b27 Convert remaining examples to links 2014-02-08 17:52:21 -05:00
Matthias Clasen
623b58eeac REmove another table 2014-02-08 15:59:24 -05:00
Matthias Clasen
d5e5244c30 Another stray litreal 2014-02-08 15:28:34 -05:00
Matthias Clasen
cd5cd874f0 Convert another table to a list 2014-02-08 15:18:37 -05:00
Matthias Clasen
3d0e55dfd5 Convert more xincluded examples to external links 2014-02-08 15:18:06 -05:00
Matthias Clasen
f04dbac47d Remove a new literal tag that has crept in 2014-02-08 13:28:11 -05:00
Matthias Clasen
c43e0c34b0 Remove a few leftover <simplelist>s 2014-02-08 13:25:04 -05:00
Matthias Clasen
3ad5aadb40 Remove a stray <em> tag 2014-02-08 13:22:58 -05:00
Matthias Clasen
e16f053aa7 Remove tables from GFileAttribute docs 2014-02-08 13:22:38 -05:00
Matthias Clasen
e7fd3de86d Eradicate links and xrefs
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
63777d0c63 Remove a few overlooked literals 2014-02-06 16:59:49 -05:00
Matthias Clasen
df990914cf Stop using replaceable tags 2014-02-06 16:49:29 -05:00
Matthias Clasen
5baa0f2af5 Stop using <para> for ids
Instead, use the id support in markdown headings.
2014-02-06 16:48:49 -05:00
Matthias Clasen
3232425785 Docs: replace <literal> by ` 2014-02-06 08:07:16 -05:00
Matthias Clasen
a35d8a4c77 Docs: use quotes instead of firstterm 2014-02-06 08:07:16 -05:00
Matthias Clasen
4569b8ac2d Stop using starttag elements 2014-02-06 08:07:15 -05:00
Matthias Clasen
73c23d9143 Use markdown for images 2014-02-06 08:07:15 -05:00
Ryan Lortie
0e671286fc GApplication: parse command line options
Add support for parsing command line options with GApplication.

You can add GOptionGroup and GOptionEntry using two new APIs:
g_application_add_option_group() and
g_application_add_main_option_entries().

Also add a "handle-local-options" signal that allows handling of
commandline arguments in the local process without having to override
local_command_line.

As a special feature, you can have a %NULL @arg_data in a GOptionEntry
which will cause the argument to be stored in a GVariantDict.  This
dictionary is available for inspection and modification by the
"handle-local-options" signal and can be forwarded to the primary
instance in cases of command line invocation (where it can be fetched
using g_application_command_line_get_options()).

https://bugzilla.gnome.org/show_bug.cgi?id=721977
2014-02-06 12:02:53 +00:00
Matthias Clasen
cb588d4532 Convert external links to markdown syntax 2014-02-05 21:23:28 -05:00
Matthias Clasen
0cc20b7e0b Don't use <filename> in docs
Switch to simpler markdown, `foo`.
2014-02-05 20:17:46 -05:00
Matthias Clasen
111803030d Don't use <envar> in docs
Switch to simpler markdown, `foo`.
2014-02-05 19:32:41 -05:00
Antoine Jacoutot
7cf221aadb gio: extend the system_internal lists with BSD paths 2014-02-02 10:08:05 +01:00
Matthias Clasen
ce87d6420c Don't use the quote tag
It was only used in two places, and we can easily do without.
2014-02-01 21:19:00 -05:00
Matthias Clasen
6566f746f6 Drop use of xinclude in GTestDBus docs 2014-02-01 20:41:47 -05:00
Matthias Clasen
95aba90d09 Docs: Remove another use of xinclude 2014-02-01 20:41:12 -05:00
Matthias Clasen
306dfb3292 Drop use of the command tag
It is more useful to link to the included man page, anyway.
2014-02-01 15:26:38 -05:00
Matthias Clasen
8bdc089ca4 Docs: Drop use of indexterm tags
These have not been making it into the index, anyway.
2014-02-01 15:25:43 -05:00
Matthias Clasen
adf892e96a Annotate all examples with their language
The C ones, at least.
2014-02-01 15:11:49 -05:00
Matthias Clasen
701f00f125 GApplicationCommandline: Shorten embedded examples
Just show relevant fragments of the three examples inline,
and link to the full sources. This lets us get rid of
xinclude markup.
2014-02-01 15:11:00 -05:00
Matthias Clasen
77c4ff80dc docs: Stop using the function tag 2014-02-01 12:19:04 -05:00
Matthias Clasen
42cf80780b Docs: Big entity cleanup
Strip lots of entity use from |[ ]| examples (which are now
implicit CDATA). Also remove many redundant uses of <!-- -->.
2014-02-01 12:00:30 -05:00
Matthias Clasen
4ab94a2683 gtestdbus: Use markdown for sections 2014-02-01 10:48:36 -05:00
Matthias Clasen
eb69bc6aa4 GSettings: use markdown for sections 2014-02-01 10:48:02 -05:00
Matthias Clasen
07506f6c57 kqueue: Don't use doc comments
This is not public API, so no need to confuse gtk-doc by
documentation that it needs to ignore. Also, no need for
markup in here.
2014-02-01 10:22:43 -05:00
Matthias Clasen
77a6014753 GApplication: Convert docs to markdown 2014-02-01 10:22:43 -05:00
Matthias Clasen
01be287689 gdbusnameowning: Convert docs to markdown 2014-02-01 10:22:43 -05:00
Matthias Clasen
3247d11704 GDBusConnection: Convert docs to markdown
And straighten out capitalization across the file.
2014-02-01 10:22:42 -05:00
Matthias Clasen
fee9194ade GIcon: Convert docs to markdown 2014-02-01 10:22:42 -05:00
Matthias Clasen
192ddc0792 GDBusProxy: Convert docs to markdown 2014-02-01 10:22:42 -05:00
Matthias Clasen
54578e4c34 GMenuModel: Convert docs to markdown 2014-02-01 10:22:42 -05:00
Matthias Clasen
4a1710862d GSimpleProxyResolver: convert docs to markdown 2014-02-01 10:22:42 -05:00
Matthias Clasen
d7b9f20990 GSocketClient: convert docs to markdown 2014-02-01 10:22:42 -05:00
Matthias Clasen
ba307a0c52 GTask: convert long desc to markdown
Use markdown sections and lists here.
2014-02-01 10:22:42 -05:00
Dan Winship
ed2bb95330 gio/tests/network-address: fix for systems with large ifindexes
In some virtualization setups, ifindexes can end up becoming very
large, and so the existing code that assumes that *some* interface
must have an index less than 255 fails.

Fix this by explicitly looking for "lo" first. And then if that fails
(on Windows, or other systems where the loopback interface is not
called "lo"), try indexes up to 1024 rather than 255.

https://bugzilla.gnome.org/show_bug.cgi?id=723048
2014-02-01 13:37:07 +01:00
Dan Winship
243b264fca gnetworkmonitornetlink: filter out IPv6 LL MC changes
For some reason, IPv6 link-local multicast routing changes all the
time. GNetworkMonitorBase was already ignoring them for purposes of
emitting network-changed, but GNetworkMonitorNetlink would still
trigger a re-dump after getting one, so network-changed would end up
getting emitted anyway.
2014-02-01 13:16:28 +01:00
Matthias Clasen
cade4d6f19 Fix the docs build 2014-01-31 22:14:01 -05:00
Matthias Clasen
a4c33c6f8b Docs: Don't use the code tag 2014-01-31 22:05:04 -05:00
Matthias Clasen
17f51583a8 Docs: Convert examples to |[ ]| 2014-01-31 21:56:33 -05:00
Matthias Clasen
4d12e0d66f Docs: Don't use the emphasis tag
Most of the time, the text read just as well without the extra
boldness.
2014-01-31 20:34:33 -05:00
Matthias Clasen
64eface479 Docs: don't use the warning tag
More markup removal
2014-01-31 18:20:06 -05:00
Matthias Clasen
c575d24dfb Docs: Don't use the note tag
More markup avoidance.
2014-01-31 18:20:06 -05:00
Colin Walters
4cbee6a35b Restore executability for other files 2014-01-31 09:36:52 -05:00
Colin Walters
a7435d2e69 Restore executability on data-to-c.pl 2014-01-31 09:23:45 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Matthias Clasen
fc04275a00 Docs: don't use the type tag
Just avoid explicit docbook markup.
2014-01-31 05:58:17 -05:00
Matthias Clasen
3d42934b71 Docs: don't use the structname tag
Just avoid explicit docbook markup.
2014-01-31 00:29:14 -05:00
Matthias Clasen
acfb76afe2 Docs: don't use <footnote>
It basically does not work in the HTML output.
2014-01-30 23:52:58 -05:00
Matthias Clasen
8548d16add Drop a no-longer-existing example from the docs
gapplication-example-menu.c was dropped in
0c094d6607, two years ago.
Time to remove its inclusion in the docs too.

https://bugzilla.gnome.org/show_bug.cgi?id=722973
2014-01-25 18:19:58 -05:00
Rico Tzschichholz
46e13e5d49 gio: Add missing transfer annotation to g_simple_proxy_resolver_new 2014-01-23 17:21:32 +01:00
Rico Tzschichholz
5ca9bee524 gio: Fix some header/source parameter-naming mismatches 2014-01-22 14:21:41 +01:00
Rico Tzschichholz
cd86c0243c gsubprocess: Add missing transfer annotations to get_*_pipe() 2014-01-22 14:06:10 +01:00
Ryan Lortie
829464a3c7 test default GSimpleAction activation
Test the default handling of the "activate" signal on GSimpleAction.

https://bugzilla.gnome.org/show_bug.cgi?id=722503
2014-01-21 15:15:38 -05:00
Jasper St. Pierre
ea22300620 gsettings: Fix annotations 2014-01-21 12:00:41 -05:00
Matthias Clasen
fc6d6b6e10 GAction: remove a lie
Not only was the link to GtkAction broken, it is not true.

https://bugzilla.gnome.org/show_bug.cgi?id=722591
2014-01-20 07:37:42 -05:00
Matthias Clasen
d102cf2b0f Fix the build
The thumbnail-verification test (indirectly) includes individual
headers, so define GIO_COMPILATION to make it work.
2014-01-19 08:58:28 -05:00
Marc-André Lureau
38a6ab3e0e win32: silence build warning
glocalfile.c: In function 'g_local_file_measure_size_of_file':
glocalfile.c:2654:3: warning: passing argument 2 of 'g_lstat' from
incompatible pointer type [enabled by default]
   if (g_lstat (name->data, &buf) != 0)
   ^
In file included from glocalfile.c:68:0:
../glib/gstdio.h:135:5: note: expected 'struct GStatBuf *' but argument
is of type 'struct _stati64 *'

https://bugzilla.gnome.org/show_bug.cgi?id=711547
2014-01-19 08:28:31 -05:00
Marc-André Lureau
a8f58fcfec win32: silence build warning
gdbusauthmechanismexternal.c: In function 'mechanism_client_initiate':
gdbusauthmechanismexternal.c:355:3: warning: 'initial_response' may be
used uninitialized in this function [-Wmaybe-uninitialized]
   return initial_response;
   ^
gdbusauthmechanismexternal.c:332:10: note: 'initial_response' was
declared here

https://bugzilla.gnome.org/show_bug.cgi?id=711547
2014-01-19 08:26:47 -05:00
Marc-André Lureau
2873b3c20c win32: silence build warning
glocalfileinfo.c: In function '_g_local_file_info_get':
glocalfileinfo.c:1955:11: warning: passing argument 3 of
'get_thumbnail_attributes' from incompatible pointer type [enabled by
default]
           get_thumbnail_attributes (path, info, &statbuf);
           ^
glocalfileinfo.c:1285:1: note: expected 'const struct GStatBuf *' but
argument is of type 'struct _stati64 *'
 get_thumbnail_attributes (const char     *path,

https://bugzilla.gnome.org/show_bug.cgi?id=711547
2014-01-19 08:25:33 -05:00
Ryan Lortie
9e81c07ad6 GSimpleAction: fix mistake in last commit
Some bad copy-paste happening here...
2014-01-18 14:27:26 -05:00
Ryan Lortie
1ec71144fb GSimpleAction: add default activate handler
If the action is stateful and the user doesn't have their own activate handler
then do some reasonable things for ourselves.

After a lot of experience using stateful GSimpleAction it turns out that
people almost always end up using it in the same ways:

A boolean-typed stateful action with no parameter is most likely going
to want to be toggled.  Any other type of action that has the parameter
type equal to the state type probably intends for activation to
represent a request to change the state.

This patch implements those two cases.  This will let people stop
writing their own trivial handlers over and over.

https://bugzilla.gnome.org/show_bug.cgi?id=722503
2014-01-18 14:19:37 -05:00
Ryan Lortie
e5f91951a1 GApplication: change commandline encoding policy
Clarify in the documentation that the commandline arguments passed
around by GApplication (to local_command_line and returned via
g_application_command_line_get_arguments()) are in the GLib filename
encoding (ie: UTF-8) on Windows, not the system code page.

Fix the mismatch that would result from having argv passed to
g_application_run() in main() on Windows (where it is in the system
code page) by ignoring argc/argv on Windows and calling
g_win32_get_command_line() for ourselves.  Document this.

This might be a slight API break on Windows: we documented that it was
possible to call g_application_run() with arguments other than argc/argv
and now doing that will result in those arguments being ignored.  It has
always been recommended practice to only call g_application_run() from
main() directly, however, and all of our code examples have shown only
this.  We will see if this causes any issues and consider reevaluating
the situation if so.

https://bugzilla.gnome.org/show_bug.cgi?id=722025
2014-01-17 20:06:37 -05:00
Ryan Lortie
643f2b348d g_file_new_for_commandline_arg: clarify encoding
Add a note to the documentation for g_file_new_for_commandline_arg()
that this function is intended to operate on strings already in the GLib
filename encoding on Windows.

This has been the case for a long time, but this documents the
requirement.

https://bugzilla.gnome.org/show_bug.cgi?id=722025
2014-01-17 20:05:41 -05:00
Marc-André Lureau
d3c729bf0e gio: fix small memory leak on local xattr
g_strconcat() allocates memory, it needs to be freed.

==10653== 1,400 bytes in 50 blocks are definitely lost in loss record
1,838 of 1,851
==10653==    at 0x4A0645D: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10653==    by 0x54ACB22: g_malloc (gmem.c:102)
==10653==    by 0x54ACE4D: g_malloc_n (gmem.c:343)
==10653==    by 0x54C8463: g_strconcat (gstrfuncs.c:589)
==10653==    by 0x4D6ED38: get_xattrs_from_fd (glocalfileinfo.c:660)
==10653==    by 0x4D71622:
_g_local_file_info_get_from_fd (glocalfileinfo.c:2028)
==10653==    by 0x4D731A0:
g_local_file_input_stream_query_info (glocalfileinputstream.c:356)
==10653==    by 0x4C996D8:
g_file_input_stream_query_info (gfileinputstream.c:148)
==10653==    by 0x4C863F6: file_copy_fallback (gfile.c:3120)
==10653==    by 0x4C86DD2: g_file_copy (gfile.c:3398)

https://bugzilla.gnome.org/show_bug.cgi?id=722357
2014-01-16 20:27:26 -05:00
Jasper St. Pierre
c4934c9358 Update .gitignore 2014-01-15 10:37:59 -05:00
Ryan Lortie
bcd276c2b4 more distcheck fixes 2014-01-13 17:23:22 -05:00
Ryan Lortie
4130118a72 giomodule test: fix again
The compiled modules will be in the G_TEST_BUILT directory, not _DIST.
2014-01-13 16:12:31 -05:00
Ryan Lortie
186965fc9b giomodule test: force shared library build
http://lists.gnu.org/archive/html/bug-libtool/2013-05/msg00009.html hit
us again.  libtool only builds .so files if we install the library, so
force it to build for our testcase, even if we don't install it.
2014-01-13 15:31:38 -05:00
Rico Tzschichholz
60cca82c9d gdesktopinfo: Fix typo in "Since" annotation of has_key 2014-01-13 12:33:35 +01:00
Ryan Lortie
d3017967d8 GApplication: allow handles_commandline and service
The default local_command_line handler has a fast return path for the
case that we handle the commandline by forwarding it to the primary
instance, but this doesn't account for the fact that we may want to
become a service.

Allow for this by making sure we don't take the fast path of the service
flag is set.
2014-01-10 11:17:44 -05:00
Ryan Lortie
e8b7dd32fc GApplication: add --gapplication-service switch
Add a --gapplication-service switch to the default implementation of
local_command_line.  This name is unlikely to clash with any option used
by an existing application.

When a normal application (neither service nor launcher) is launched with
exactly this one argument, G_APPLICATION_IS_SERVICE will be set.

The idea is that people will write their D-Bus service file with
--gapplication-service on the Exec line.  This provides a nice
compromise for people who want the benefits of DBusActivatable
applications but without losing the ability to easily run them directly
(under the debugger or inside jhbuild, etc.)

https://bugzilla.gnome.org/show_bug.cgi?id=710965
2014-01-09 16:15:53 -05:00
Ryan Lortie
8bc63b0ef0 gdbus-introspection test: test escaping attributes
Make sure attribute values are properly escaped in generated XML.

https://bugzilla.gnome.org/show_bug.cgi?id=721796
2014-01-08 22:58:06 -05:00
Ryan Lortie
04ee782486 gdbus: properly escape introspection annotations
Make sure we escape any special characters that are found in annotation
names or values to avoid emitting a malformed XML document in response
to an Introspect call.

https://bugzilla.gnome.org/show_bug.cgi?id=721796
2014-01-08 22:58:06 -05:00
Matthias Clasen
3872049445 Add includes to all gio docs 2014-01-07 22:55:43 -05:00
Chun-wei Fan
589aed9383 gio/tests/giomodule.c: Use G_MODULE_SUFFIX
The file extension of the GIO module could be something other than .so,
depending on platform.  Use G_MODULE_SUFFIX so that the test will run
correctly on non-*nix platforms, such as Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=719344
2014-01-04 10:44:17 +08:00
Matthias Clasen
2b289cc565 Fix make install with --disable-installed-tests
If installed tests are not enabled, installed_testdir is not
defined, so we end up trying to create /modules and to chmod
things in /x-content/, which is not right.
2014-01-02 13:36:37 -05:00
Ryan Lortie
c09cfc1c8a GFile: fix uninitialised variable
clang cause the fact that some of our 'goto out;' cases cause use to try
and free an uninitialised GString.  Fix that up.
2014-01-02 12:54:12 -05:00
Ryan Lortie
51b3dd7332 GDBusConnection: don't write to stdout
When losing the D-Bus connection, we would write to stdout about it just
before killing ourselves with SIGTERM.  We're a library, so we should
probably use stderr instead.

https://bugzilla.gnome.org/show_bug.cgi?id=721324
2014-01-02 10:08:55 -05:00
Ryan Lortie
8976175ba9 gsettings: tweak test for last commit
The last commit changed the behaviour of child objects of delayed
GSettings.  Adjust the testcase accordingly.
2014-01-02 01:55:07 -05:00
Ryan Lortie
c7636ce64b g_settings_get_child(): inherit backend
Part of the purpose of g_settings_get_child() was that it could be used
after you delay() a GSettings object, and then apply() all of the
settings together.  In order for that to work, we need to share the
backend.

https://bugzilla.gnome.org/show_bug.cgi?id=720891
2014-01-02 01:50:40 -05:00
Matthias Clasen
11ddb843b9 Make /contenttype/tree test work installed
The x-content/win32-software type is only recognized if
the autorun.exe file is executable. Since the file is installed
as data, we need to fix up its permissions in an
install-data-hook.
2014-01-01 22:30:24 -05:00
Matthias Clasen
dba1ae12a8 Avoid a compiler warning 2014-01-01 22:01:15 -05:00
Colin Walters
97d9138f6c gio/tests: Fix usage of BUILT_SOURCES 2014-01-01 19:05:34 -05:00
Matthias Clasen
680c348bb4 Add missing includes
config.h needs to be included in every source file, first.
2014-01-01 17:59:21 -05:00
Matthias Clasen
2299bcd88d Improve GResourceFile test coverage 2014-01-01 17:59:21 -05:00
Matthias Clasen
3eeeb7aaa7 Improve gsettings test coverage 2014-01-01 17:59:21 -05:00
Matthias Clasen
1041fc2190 Improve gdbus test coverage 2014-01-01 17:59:21 -05:00
Matthias Clasen
df3ac947ac Improve converter test coverage 2014-01-01 17:59:21 -05:00
Matthias Clasen
354ae1d61c Add tests for remote actions
This improves the GApplication test coverage.
2014-01-01 17:59:21 -05:00
Matthias Clasen
8aeb391a77 Improve GIOModule test coverage
Add a dedicated test for GIOModule.
2014-01-01 17:59:21 -05:00
Matthias Clasen
7bea4bd89a Correct a doc comment 2014-01-01 17:59:21 -05:00
Matthias Clasen
5bcbb98f45 GIOModule: Add some more details to the docs 2014-01-01 17:59:21 -05:00
Matthias Clasen
0356d7f4c3 Fix a typo in a comment
The D-Bus interface is org.freedesktop.DBus.Peer, not
org.freedesktop.DBus.
2014-01-01 17:59:21 -05:00
Matthias Clasen
b5ba22f163 Add a generic property test
This test is inspired by its namesake in GTK+. We instantiate
all types, and check the default values of their properties,
with some exceptions for types that are known not to work.
2014-01-01 17:59:21 -05:00
Matthias Clasen
290b46cd24 GTlsPassword: Make declared defaults match
String properties typically start out with a value of NULL.
No reason to deviate from that convention here.
2014-01-01 17:59:20 -05:00
Matthias Clasen
3a37e403e6 Make GFileIcon more robust
No reason not to survive g_object_unref (g_object_new (...))
2014-01-01 17:59:20 -05:00
Matthias Clasen
34de9189f6 Make GEmblem more robust
No reason not to survive g_object_unref (g_object_new (...)).
2014-01-01 17:59:20 -05:00
Matthias Clasen
62b28546af Trivial formatting fixes 2014-01-01 17:59:20 -05:00
Matthias Clasen
6c75ba2b90 Add tests for x-content type sniffing
This test exercises the tree matching parts of gcontenttype.c
2014-01-01 17:59:20 -05:00
Matthias Clasen
159459bc2d Simplify fileattributematcher tests a bit
Just use assertions instead of pretty-printed error messages.
2014-01-01 17:59:20 -05:00
Matthias Clasen
3bbfd90880 Improve GApplicationCommandline test coverage
Add tests for many GApplicationCommandline apis to the
existing application tests.
2014-01-01 17:59:20 -05:00
Matthias Clasen
7846d6154a Improve GSubprocess test coverage
Test the synchronous communicate functions.
2014-01-01 17:59:20 -05:00
Matthias Clasen
e021bb9101 Improve GInitable test coverage
This just adds a bit more variety to the uses of GInitiable
in other tests.
2014-01-01 17:59:20 -05:00
Jasper St. Pierre
0c87f71521 codegen: direction defaults to "in" 2013-12-31 15:39:02 -05:00
Antoine Jacoutot
fb21c8eaab kqueue: fix a potential deadlock
In case an object is already monitored, we lock then return without
unlocking it which can then result in a self deadlock. So properly
unlock before returning.

https://bugzilla.gnome.org/show_bug.cgi?id=721074
2013-12-26 19:57:44 +01:00
Morten Welinder
c26c557908 gsubprocesslauncher: Use "env" instead of "environ"
The latter may come from system headers.

https://bugzilla.gnome.org/show_bug.cgi?id=721059
2013-12-26 07:37:17 -05:00
Matthias Scheler
091e466095 gio: Fix return of value from void function
https://bugzilla.gnome.org/show_bug.cgi?id=721034
2013-12-25 13:57:56 -05:00
Ryan Lortie
ee5dab6bb5 gdbus tool: print GVariant errors in context
Use g_variant_parse_error_print_context() to format the error message
from the GVariant parser.

There is a slightly dubious interaction with the "parse me harder"
functionality here.  We're probably going to have to deal with that
separately.

https://bugzilla.gnome.org/show_bug.cgi?id=715028
2013-12-22 11:41:45 -05:00
Ryan Lortie
94a89f6c2f gapplication(1): print GVariant errors in context
Use g_variant_parse_error_print_context() to format the error message
from the GVariant parser.

https://bugzilla.gnome.org/show_bug.cgi?id=715028
2013-12-22 11:41:44 -05:00
Ryan Lortie
420f90d849 gsettings tool: print GVariant errors in context
Use g_variant_parse_error_print_context() to format the error message
from the GVariant parser.

https://bugzilla.gnome.org/show_bug.cgi?id=715028
2013-12-22 11:41:43 -05:00
Ryan Lortie
3f41e49285 Use POSIX-specified <poll.h> over <sys/poll.h>
POSIX specifies that <poll.h> is the correct header to include for
poll(), so let's do that instead.

https://bugzilla.gnome.org/show_bug.cgi?id=141251
2013-12-22 11:33:07 -05:00
Matthias Clasen
864d960d75 More settings backend tests
This adds some more test coverage around writability changes
in the keyfile and delayed settings backends.
2013-12-22 00:44:56 -05:00
Matthias Clasen
41a8296e11 GKeyfileSettingsBackend: Use a directory monitor
GKeyfileSettingsBackend was using a file monitor to monitor
the parent directory of its keyfile.
2013-12-22 00:43:44 -05:00
Matthias Clasen
3c873e7617 More test coverage for settings backends 2013-12-21 16:49:52 -05:00
Matthias Clasen
dac1ad66eb Improve gsettings test coverage
Deal with corner cases around delay.
2013-12-21 13:22:00 -05:00
Matthias Clasen
fc828c4de8 contenttype tests: better assertions
I recently had to track down why these tests failed. Turned
out that some rogue package on my system had installed mime
types that declared all files with 3 letter names to be
'chemical/x-turbomole-vibrational'.
This change will make it more obvious what is going on by
mentioning the mime types in the assertion message.
2013-12-21 13:22:00 -05:00
Matthias Clasen
6d8ac1125e Slightly improve coverate for notification tests 2013-12-21 13:22:00 -05:00
Matthias Clasen
5ab9e21d7a Improve test coverage for GPropertyAction 2013-12-21 13:22:00 -05:00
Matthias Clasen
f9747d07c8 Test some gsettings corner case
Setting a strv to NULL was not tested before.
2013-12-21 13:22:00 -05:00
Bastien Nocera
c300079f13 gdbus-codegen: Fix crasher in goa-using apps
When replacing a version of goa-daemon (from gnome-online-accounts)
by a newer version with some added interfaces, evolution-data-server
and the gvfs-goa volume monitor might crash as there's no interface
definition for this new interface.

Work-around this by returning earlier from the _notify() implementation,
rather than accessing invalid memory.

https://bugzilla.gnome.org/show_bug.cgi?id=720539
2013-12-18 10:53:01 +01:00
Matthias Clasen
5ccdf2b86a Expand the truncate tests
Check that the data is expanded with zeros.
2013-12-15 21:07:12 -05:00
Matthias Clasen
453a69534c Update tests for new truncate behavior 2013-12-15 21:07:12 -05:00
Stef Walter
baed90af43 gdbus-export: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-12-15 21:07:11 -05:00
Stef Walter
db6a297d9e gdbus-auth: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-12-15 21:07:11 -05:00
Colin Walters
2ad121ab16 gsubprocesslauncher: Annotate g_subprocess_launcher_spawnv()
Needs to be an array.
2013-12-15 20:44:53 -05:00
Matthias Clasen
0b486a49e4 Fix up gsettings test 2013-12-15 18:50:49 -05:00
Ross Lagerwall
3b9ad6e6ef gio: Update GMemoryOutputStream length after truncate
For GMemoryOutputStream, update valid_len when truncating so that
g_memory_output_stream_get_data_size () returns the correct result.

https://bugzilla.gnome.org/show_bug.cgi?id=720080
2013-12-15 11:54:39 -05:00
Matthias Clasen
c34cc2348c Simplify subprocesses in tests
Use the new way of running tests in a subprocess without
registering extra 'subprocess' test cases where appropriate.
2013-12-15 11:50:00 -05:00
Chun-wei Fan
3af58d2e9f gio/gdbusaddress: Clean up Win32 code a bit
Combine duplicate parts into one, as the symbol used by RunDLL under x64
is the same for either Visual C++ or MinGW-64
2013-12-12 18:00:52 +08:00
Martin Pitt
e6c86d58f2 gdesktopappinfo: Add missing annotations
Add missing (allow-none) annotations to
g_desktop_app_info_launch_uris_as_manager(). Tested with

  python -c "from gi.repository import GLib, Gio; Gio.DesktopAppInfo.new('gcalctool.desktop').launch_uris_as_manager([], None, GLib.SpawnFlags.SEARCH_PATH|GLib.SpawnFlags.STDOUT_TO_DEV_NULL, None, None, None, None)"

which is necessary to do a launch_uris() without leaking stdout.

https://launchpad.net/bugs/1259721
2013-12-11 13:17:10 +01:00
Manuel Bachmann
36ef409591 gdbus-codegen: look for deps in correct path under win32
codegen.py and friends get installed in "share/glib-2.0",
so look for them there.

https://bugzilla.gnome.org/show_bug.cgi?id=702862
2013-12-11 11:02:33 +01:00
Stef Walter
e6456bcfb6 gdbus-connection: Work around race in connection tests
GDBusConnection cleanup is inherently racy due to its use of worker
threads. Put tests that expect a NULL G_BUS_TYPE_SESSION singleton
as the first tests to work around cleanup races.

https://bugzilla.gnome.org/show_bug.cgi?id=719837
2013-12-11 07:32:03 +01:00
Lars Uebernickel
0f1579e62c g_settings_get: only check for non-copying format string
396d40af introduced a redundant call to g_variant_check_format_string().
Checking whether the format string copies all values is enough.

https://bugzilla.gnome.org/show_bug.cgi?id=719979
2013-12-09 15:51:56 +01:00
Ryan Lortie
ddf82a2576 [PATCH] Fix trivial non literal format uses
Based on a patch from Henrique Dante de Almeida <hdante@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=691608
2013-12-08 14:22:51 -05:00
Lars Uebernickel
396d40af23 g_settings_get: check validity of format string
Allow only format strings that copy all values (i.e, don't contain '&'),
as the returned pointers might become invalid in some rare cases.

Since this is technically an API break, this patch only prints a
critical when a faulty format string is detected, but still fetches the
values.

https://bugzilla.gnome.org/show_bug.cgi?id=719979
2013-12-06 16:48:00 +01:00
Philip Withnall
c07eccd9c2 gtestdbus: Add a note about thread safety to the documentation
https://bugzilla.gnome.org/show_bug.cgi?id=712148
2013-12-06 09:41:56 +00:00
Daiki Ueno
7e9e7a66a1 Fix documentation typos in GTask and GCancellable examples
https://bugzilla.gnome.org/show_bug.cgi?id=719884
2013-12-06 07:55:27 +09:00
Xavier Claessens
0f800cd1a8 Document clearly async functions not copying its args
Usually async methods copy/ref its arguments so caller can
forget about them. g_file_replace_contents_async() and
g_output_stream_write_async() are exceptions.

https://bugzilla.gnome.org/show_bug.cgi?id=690525
2013-12-02 14:45:42 -05:00
Xavier Claessens
c4e9135352 GFile: add GBytes version of _replace_contents_async()
https://bugzilla.gnome.org/show_bug.cgi?id=690525
2013-12-02 14:45:42 -05:00
Colin Walters
10d2a01c9a gsubprocess: Annotate g_subprocess_newv()
So that it can actually be invoked by bindings.
2013-12-01 22:00:27 -05:00
Matthias Clasen
a812e110bf Install all test data
The desktop-files directory contains a mimeapps.cache file
that was not installed as data for installed tests, causing
the file measure test to fail only in when installed.
2013-12-01 11:47:00 -05:00
Matthias Clasen
72eae6eddd Improve file measure testcase
Make the testcase compare the byte size to what is reported
by du. Also add a test for the async api, and mak eit test
the progress reporting callback.
2013-11-30 23:10:13 -05:00
Philip Withnall
9d4cd9c5ae gtestdbus: Minor documentation fixes
https://bugzilla.gnome.org/show_bug.cgi?id=712148
2013-11-29 08:11:13 +00:00
Philip Withnall
46c1aea0e7 gtestdbus: Fix non-const use of const variables
The argv array should be declared as const.

https://bugzilla.gnome.org/show_bug.cgi?id=712148
2013-11-29 08:11:13 +00:00
Philip Withnall
598a9c5028 gtestdbus: Fix variable shadowing
Shut up, GCC.

https://bugzilla.gnome.org/show_bug.cgi?id=712148
2013-11-29 08:11:13 +00:00
Matthias Clasen
b328cae6a9 Add a test for g_file_measure_disk_usage 2013-11-29 00:12:43 -05:00
Colin Walters
7a90c201f7 tests/gsubprocess: Only compare basename of /tmp
Otherwise, we break in Continuous where /tmp == /sysroot/tmp,
and something in the execve() or the kernel will do realpath()
for us.
2013-11-29 04:12:26 +00:00
Matthias Clasen
2cafe37e19 Improve GApplication test coverage
Exercise more of the GActionMap implementation.
2013-11-28 21:57:47 -05:00
Matthias Clasen
5528a0f408 Improve GNotification test coverage 2013-11-28 21:56:48 -05:00
Matthias Clasen
97a06b4252 Improve GSimpleActionGroup test coverage
Add a case that overwrites an existing action.
2013-11-28 21:53:53 -05:00
Matthias Clasen
dbe560ac01 Improve GSettings test coverage
This covers some more GSettingsSchemaKey api.
2013-11-28 16:01:23 -05:00
Matthias Clasen
00ab7790ce Improve GNotification test coverage 2013-11-28 16:01:23 -05:00
Matthias Clasen
a688b2a9c0 Improve test coverage for GSubprocess 2013-11-28 16:01:23 -05:00
Matthias Clasen
f18138a9cf Improve test coverage for gsettings 2013-11-28 16:01:23 -05:00
Matthias Clasen
9a02cfd914 Test new gsettings api
g_settings_get_user_value and g_settings_get_default_value
are now covered.
2013-11-28 16:01:23 -05:00
Philip Withnall
49ea52e6a6 gio: Replace g_clear_object() with if()…g_object_unref()
As per https://bugzilla.gnome.org/show_bug.cgi?id=113075#c39.
2013-11-28 20:41:49 +00:00
djcb
49fc6d5b7e gdbus-codegen: Fix leak in property setter
Comparing the code generated for the setter and other methods without
(real) return value, I noticed that the setter does not unref the
gvariant it gets.

https://bugzilla.gnome.org/show_bug.cgi?id=719472
2013-11-28 08:25:20 -05:00
Matthias Clasen
7d82d6dc5b Test g_subprocess_launcher_spawn
The spawnv variant of this function already had a test, but
spawn was not tested.
2013-11-28 01:36:29 -05:00
Matthias Clasen
7ef1eccd7e Fix g_subprocess_launcher_spawn
This function turns a varargs argument list into a string array,
but forgets to NULL-terminate it. This function was not covered
by unit tests...so it was broken.
2013-11-28 01:34:52 -05:00
Matthias Clasen
4a687ed723 Test some more GSubProcess api
This covers g_subprocess_set_environ, g_subprocess_setenv,
g_subprocess_getenv, and g_subprocess_set_flags.
2013-11-28 01:12:26 -05:00
Matthias Clasen
bd932aa9f8 Add a GAppInfoMonitor test
The test reveals that there's something fishy with this monitor.
One has to call g_app_info_get_all() for it to start working,
and then it only works once.
2013-11-28 00:19:19 -05:00
Matthias Clasen
36a42ab0a5 Add tests for new GAction api
g_action_name_is_valid and g_action_parse_detailed_name are
now covered.
2013-11-27 22:48:06 -05:00
Manuel Bachmann
1e3fe29fc3 Fix g_win32_run_session_bus hook for MinGW-w64
On win64, g_win32_run_session_bus gets exported with this
precise name, with MinGW as well as MSVC.

Fixes annoying "Entry not found" UI warning.
2013-11-27 23:18:54 +01:00
Ryan Lortie
43d19dae11 gsettings tool: stop using GMainLoop
Just iterate directly.
2013-11-27 12:42:32 -05:00
Ryan Lortie
f33a7f9ef2 gsettings tool: fix some sed damage
The previous patch to simplify the GSettings commandline tool by making
more use of global variables went a bit too far and broke 'gsettings
monitor' when used without a specific key.

Fix that up again.
2013-11-27 12:42:32 -05:00
Rui Matos
1300108e0c GDBusObjectManagerClient: keep the manager alive while firing signals
Handlers for the signals we emit might unref the object manager. Make
sure we keep it alive until we are done with it.

https://bugzilla.gnome.org/show_bug.cgi?id=719402
2013-11-27 16:18:19 +01:00
Philip Withnall
c9344fd513 gio/tests: Add a dynamic type check assertion
This shuts up a static analysis false positive, and adds some extra
checking.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:30 +00:00
Philip Withnall
32118951ea gio/tests: Add a non-NULL assertion to help static analysis
The static analyser (correctly) considers a type check to fail if the
variable is NULL. In this case, the address must be non-NULL as no error
was thrown by g_socket_connection_get_remote_address(), but the static
analyser doesn’t know this.

Add a non-NULL assertion anyway, both to shut the analyser up, and
because it’s good extra testing.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:30 +00:00
Philip Withnall
c9ccc2af91 gio/tests: Add non-NULL assertions to help static analysis
These prevent some false positives from the static analyser which are
caused by it not inspecting the invariants of
g_subprocess_communicate[_utf8]_finish() (i.e. that stdout and
stdout_str will always be set unless an error was returned).

They’re also good testing anyway.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
fe004445a4 gio/tests: Fix a g_return_val_if_fail() in a void function
Should be g_return_if_fail() instead.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
73e6b900d4 gunixmounts: Fix a potential strcmp(NULL) call
mntent->mnt_fsname may be NULL at this point; if so, fall to the second
branch and set mount_entry->device_path = NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
8b9e8dc53b gcontenttype: Fix a potential NULL pointer dereference
If the initial part of the header (‘MIME-TreeMagic’) is valid, but the
following line does not start with ‘[’ (i.e. is not a valid section
line), insert_matchlet() will be called with a NULL match pointer, and
will crash with a NULL pointer dereference.

Fix this by bailing out if a valid section line isn’t encountered before
the first insert_matchlet() call (i.e. between the header line and the
first data line).

Note that this has not been tested against a real treemagic file; the
fix is purely theoretical.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
aa28ced44e gunixfdlist: Fix a potential NULL pointer dereference
In the case that (n_fds == 0 && fds == NULL), memcpy() would be called
against a NULL src pointer. Even though the number of bytes to copy is
0, avoid the possibility of a crash by only calling if fds is non-NULL.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
956c58c7f2 gsocketaddress: Add an assertion to help static analysis
The static analyser will check dynamic type assertions and assume that
if they fail, the variable can either have the wrong type, or be NULL
(which is correct). The analyser doesn’t know that other constraints in
the API ensure the variable is non-NULL.

Add a non-null assertion to help the static analyser and shut it up in
this case.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
c729f416fb gdbusserver: Fix a potential g_object_unref(NULL) call
This can happen if the hash table lookup for ‘noncefile’ fails, and
hence the first ‘goto out’ is hit, at which point resolver is still
NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Philip Withnall
44af12aba1 gcontenttype: Fix a potential g_object_unref(NULL) call
This can happen if the g_file_query_info() call fails, returning NULL.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=113075
2013-11-27 10:01:29 +00:00
Chun-wei Fan
b9322bf9ab gio/tests/memory-output-stream.c: Avoid an uninitialized variable
Be a little bit more careful in regards to initializing a primitive type
variable before passing it by reference, as it could have random stuff
in the variable's address depending on the CRT, such as MSVCR110.DLL,
causing random, invalid stuff being written in that address.

This will fix this test when built with Visual Studio 2012.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-27 08:01:47 +08:00
Michael Natterer
32cfcc8740 gio: remove precondition checks from g_output_stream_printf()
because we call g_output_stream_vprintf() which does exactly the same
checks.
2013-11-26 23:00:52 +01:00
Michael Natterer
d86396f21f gio: add g_output_string_[v]printf()
which are useful for porting FILE* based output code.
2013-11-26 11:51:24 +01:00
Chun-wei Fan
a997cfe90f gio/gdbusauthmechanismsha1.c: Move G_OS_* checks down
The G_OS_* checks are only valid if the GLib headers have been previously
included, so that io.h can be included properly on Windows
2013-11-26 13:16:15 +08:00
Colin Walters
03bf43e14a gsubprocess: Document g_subprocess_get_identifier() 2013-11-25 18:39:46 -05:00
Philip Withnall
299bcbfa41 gsubprocess: Fix potential strlen(NULL) calls
Also clarify the nullability of stdin_buf arguments in GSubprocess
communication calls.

Found with scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=715164
2013-11-25 15:46:51 +00:00
Manuel Bachmann
1fb4b3b2bf Fix G_OS #ifdefs in gbusserver.c
G_OS #ifdefs are only available once glibconfig.h has been
evaluated ; that is, after including glib headers.
Move this block down so it gets correctly evaluated.
2013-11-24 04:51:21 +01:00
Matthias Clasen
5efc038e0d Fix up appinfo test
Make it possible to skip the terminal-launching test simply
by setting DISPLAY= . Previously, you had to unset DISPLAY,
which is a little more cumbersome.

https://bugzilla.gnome.org/show_bug.cgi?id=711178
2013-11-23 22:24:51 -05:00
Matthias Clasen
0fc0754e65 Fix up the appinfo test
One testcase was launching appinfo-test from a GAppInfo that
does not have a filename. In this case, the G_LAUNCHED_DESKTOP_FILE
envvar is not exported. Make appinfo-test deal with that, without
spewing warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=711178
2013-11-23 22:21:29 -05:00
Matthias Clasen
0250d185b1 Fix warnings in a the actions test
The actions test tests the GSimpleActionGroup API. Maybe this
should be moved to use GActionMap, but for now, just disable
the deprecations.

There was also one test that wasn't actually hooked up, so
do that as well.
2013-11-23 21:28:40 -05:00
Christian Persch
bd8fb391aa application: Use printerr for runtime errors
g_critical can be fatal (with --g-fatal-warnings, or some env var set),
so don't use it to print out runtime errors.

Bug #676761.
2013-11-23 18:16:41 -05:00
Matthias Clasen
e45372895d Fix desktop-app-info test
The recent change to the search scoring algorithm made
nautilus and konqueror switch places in the search results.
Update the test to reflect that.
2013-11-23 18:15:04 -05:00
Stef Walter
baf92d09d6 gtestdbus: Properly close server connections
Otherwise g_test_dbus_down() following a g_test_dbus_stop()
will hang until it times out.

https://bugzilla.gnome.org/show_bug.cgi?id=711807
2013-11-23 17:37:58 -05:00
Stef Walter
5a5aaa203a gdbus-connection: Fix race condition in test
The test was expecting that the spawned process wouldn't start
up before the NameOwnerChanged signal was subscribed.

https://bugzilla.gnome.org/show_bug.cgi?id=711805
2013-11-23 15:20:51 -05:00
Lars Uebernickel
65da592249 Add basic test for the GNotification gtk backend
https://bugzilla.gnome.org/show_bug.cgi?id=711051
2013-11-23 15:11:09 -05:00
Stef Walter
797959f05a gtestdbus: Don't destroy GSource twice
https://bugzilla.gnome.org/show_bug.cgi?id=711806
2013-11-23 13:47:29 -05:00
Bastien Nocera
aef0adc0dd GSettings: More docs for deprecated _list_schemas()
Most _list_schemas() uses were to check for the availability
of a particular schema. g_settings_schema_source_lookup() is
a better way to do this.

https://bugzilla.gnome.org/show_bug.cgi?id=712315
2013-11-23 13:35:52 -05:00
Andrew Walton
4382e8b876 CLOEXEC fix for older FreeBSDs and OS X.
Some older POSIX-flavored operating systems may not have adopted
O_CLOEXEC yet.

See https://bugzilla.gnome.org/show_bug.cgi?id=712136.
2013-11-23 11:01:29 -05:00
Stef Walter
e3babb3687 giomodule: Allow overriding source directory gio modules are loaded from
When testing (and valgrinding) we need to have a known set of modules
loaded.

https://bugzilla.gnome.org/show_bug.cgi?id=711801
2013-11-23 01:17:03 -05:00
Dan Winship
8f5b40c046 gio/tests: fix output of gdbus-proxy-threads and gdbus-threading
Make gdbus-proxy-threads and gdbus-threading print a newline at the
end of their progress strings, to avoid messing up their TAP-format
output.

https://bugzilla.gnome.org/show_bug.cgi?id=711796
2013-11-23 00:43:54 -05:00
Dan Winship
c762a3a3f6 gio/tests: basic-application is a helper program, not a test
https://bugzilla.gnome.org/show_bug.cgi?id=711796
2013-11-23 00:43:53 -05:00
Dan Winship
158dde0507 Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:25:39 -05:00
Dan Winship
3981cddbf8 Require POSIX.1 (1990) compliance on unix
Assume unix platforms support the original POSIX.1 standard.
Specifically, assume that if G_OS_UNIX, then we have chown(),
getcwd(), getgrgid(), getpwuid(), link(), <grp.h>, <pwd.h>,
<sys/types.h>, <sys/uio.h>, <sys/wait.h>, and <unistd.h>.

Additionally, since all versions of Windows that we care about also
have <sys/types.h>, we can remove HAVE_SYS_TYPES_H checks everywhere.

Also remove one include of <sys/times.h>, and the corresponding
configure check, since the include is not currently needed (and may
always have just been a typo for <sys/time.h>).

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:17:42 -05:00
Dan Winship
6e4a7fca43 Require C90 compliance
Assume all supported platforms implement C90, and therefore they
(correctly) implement atexit(), memmove(), setlocale(), strerror(),
and vprintf(), and have <float.h> and <limits.h>.

(Also remove the configure check testing that "do ... while (0)" works
correctly; the non-do/while-based version of G_STMT_START and
G_STMT_END was removed years ago, but the check remained. Also, remove
some checks that configure.ac claimed were needed for libcharset, but
aren't actually used.)

Note that removing the g_memmove() function is not an ABI break even
on systems where g_memmove() was previously not a macro, because it
was never marked GLIB_AVAILABLE_IN_ALL or listed in glib.symbols, so
it would have been glib-internal since 2004.

https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-11-20 09:16:16 -05:00
Michael Haubenwallner
b1af471a3f build: Give internal libraries higher precedence
Linking local libraries too late may cause preinstalled libraries to
get found earlier, due to external library paths in .la files.

https://bugzilla.gnome.org/show_bug.cgi?id=712314
2013-11-19 08:11:35 -05:00
Colin Walters
a46459b000 GSocketClient: For _CONNECTING event, make remote address accessible
My application (hotssh) would like to get the resolved address from DNS,
before we start the connect().

We could add a new event, but it's easy enough to just cache it on the
GSocketConnection; this avoids any new API.

https://bugzilla.gnome.org/show_bug.cgi?id=712547
2013-11-18 17:13:34 -05:00
Michael Haubenwallner
efb1701bf3 Use AC_HEADER_MAJOR
Instead of checking for sys/mkdev.h headerfile, there is the
AC_HEADER_MAJOR helper for how to get major(), minor(), makedev().

https://bugzilla.gnome.org/show_bug.cgi?id=712314
2013-11-18 14:47:53 -05:00
Dan Winship
f79e39154d GDummyTlsBackend: cache the GDummyTlsDatabase
The default GTlsDatabase is supposed to be a singleton (and libsoup
has tests that will fail if it's not).
2013-11-17 09:45:20 -05:00
Ryan Lortie
ca830f2733 Fix GSettings testcase again
Hopefully this one will work for both srcdir == builddir and not.
2013-11-15 15:32:09 -05:00
Florian Müllner
2fb8901b64 gdesktopappinfo: Rank Keywords matches higher than GenericName
It makes sense to match on GenericName in case an application does
not provide any keywords, but the Keywords field has been added
to explicitly support the search case, while GenericName was used
to be displayed in menus, so it makes more sense to consider
Keywords more (or equally) relevant for search.

https://bugzilla.gnome.org/show_bug.cgi?id=711640
2013-11-13 16:54:02 +01:00
Ryan Lortie
ce35c08c57 Revert "gdbus-connection-loss: Fix leak in test"
This reverts commit 670379b26f.

This is causing distcheck to fail and will have to be revisited later.
2013-11-12 00:05:09 -05:00
Ryan Lortie
5c4f3f4dab gsettings test: fix srcdir != builddir
Just copy the schemas to the builddir and compile them in place instead
of trying to mess around with creating the compiled file in a different
dir.  This solves issues in the summary/description testcase when
GSettings expects the usual situation of having the .xml files present
in the same directory.
2013-11-12 00:05:04 -05:00
Stef Walter
1e5e3b64a8 gsubprocess: Fix a number of leaks and a segfault
Fixed a number of leaks in gsubprocess, as well as a segfault
that was hidden by never calling g_subprocess_communicate_state_free().

https://bugzilla.gnome.org/show_bug.cgi?id=711803
2013-11-11 17:41:39 +01:00
Stef Walter
a638be8a79 Revert "giomodule: Fix leaks in module loading"
This reverts commit dc72039c16.

This depends on a patch that allows GTypeModule to be finalized.
Lets put this back in bugzilla until that gets in.
2013-11-11 17:17:10 +01:00
Chun-wei Fan
0212ab6182 Tests: Fix up the expected messages
There was an expected messages that was not in the form that GLib on
Windows actually produces, which causes some test to fail.  Fix this up.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-11 22:40:57 +08:00
Chun-wei Fan
b27a2d436b gio/tests/gsubprocess.c: Fix on Windows
We need to check for the correct line endings on Windows (\r\n) for the
echo tests and currently need to skip the test_echo_eof test there, as
it depends on the cat utility that is not normally found on Windows, and
using an external installation of cat via MSYS or Cygwin would render the
test program to hang as cat waits for user input.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-11 22:38:05 +08:00
Dan Winship
fff14a5b7c gcancellable: don't use g_cancellable_connect() in GCancellableSource
g_cancellable_connect() is documented as calling its callback only
once, but GCancellableSource should trigger every time the cancellable
is cancelled.

https://bugzilla.gnome.org/show_bug.cgi?id=710691
https://bugzilla.gnome.org/show_bug.cgi?id=711286
2013-11-11 09:28:07 -05:00
Stef Walter
670379b26f gdbus-connection-loss: Fix leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 08:46:45 +01:00
Stef Walter
14b27eaab8 gdbus-introspection: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 08:46:33 +01:00
Stef Walter
dc72039c16 giomodule: Fix leaks in module loading
https://bugzilla.gnome.org/show_bug.cgi?id=711798
2013-11-11 07:22:48 +01:00
Stef Walter
91c8fb82fe gdbus-connection: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:12:53 +01:00
Stef Walter
f80e2695e1 gdbus-connection-slow: Fix leak in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:12:37 +01:00
Stef Walter
0d51ff79ed gdbus-connection: Fix use after free in test
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:12:26 +01:00
Stef Walter
95526b5db5 gsubprocess: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:12:18 +01:00
Stef Walter
fe3c878c53 gsubprocess: Fix error detection logic in tests
Various tests were depending on local_error being set by a callback
when it could never have been the case. Simplify async error detection
logic in those cases, and fix leak of GError.

https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:12:00 +01:00
Stef Walter
78ad171da9 g-icon: Fix memory leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:11:29 +01:00
Stef Walter
faafd4c051 contexts: Fix memory leak in test
https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:11:22 +01:00
Stef Walter
438f7110f9 data-output-stream: Fix some access after free
The memory pointed to by a GMemoryOutputStream can be realloc'd

https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:11:14 +01:00
Stef Walter
72171240cc buffered-output-stream: Fix some access after free
The memory pointed to by a GMemoryOutputStream can be realloc'd

https://bugzilla.gnome.org/show_bug.cgi?id=711802
2013-11-11 07:10:59 +01:00
Stef Walter
419b47e166 gtestdbus: Fix leak of GMainLoop
https://bugzilla.gnome.org/show_bug.cgi?id=711808
2013-11-11 06:55:09 +01:00
Michael Catanzaro
ae6dbb35cb giomodule: small typo in documentation 2013-11-09 09:35:14 -06:00
Matthias Clasen
0cb8454b5c Small documentation improvement 2013-11-08 20:57:04 -05:00
Rico Tzschichholz
83d4278197 Revert "gio/Makefile: make sure to dist gappinfoprivate.h"
This reverts commit c45b26d61f.
2013-11-08 08:15:43 +01:00
Ryan Lortie
bda60c3e8b GAppInfoMonitor: don't try to use NULL hash table
Don't g_hash_table_iter_init() on a NULL table if we see the app info
monitoring but no monitors have been created yet.

https://bugzilla.gnome.org/show_bug.cgi?id=711632
2013-11-07 13:56:56 -05:00
Ryan Lortie
ffbf866d3b GApplication: fix bogus testcase
We had a GApplication testcase that handled both open and commandline.
This only way that this worked was by implementing the commandline
handler without actually setting the HANDLES_COMMAND_LINE flag.

This behaviour is now invalid, so just rip out the offending part of the
test.

https://bugzilla.gnome.org/show_bug.cgi?id=711099
2013-11-07 13:51:05 -05:00
Ryan Lortie
6e0bbd8adb appinfo: Add some testcases for searching
https://bugzilla.gnome.org/show_bug.cgi?id=711557
2013-11-07 12:41:27 -05:00
Ryan Lortie
3d32d5359a Add g_desktop_app_info_search()
The first time this function is called we load all of the keyfiles in
the directory, ignoring the 'Hidden' ones and build an index out of the
interesting fields using g_str_tokenize_and_fold().

We do prefix matching on the tokens to find relevent desktop files.

Right now this is implemented as a hashtable that we iterate over,
checking prefixes on each token.  This could possibly be sped up by
creating an array, but it's already pretty fast...

https://bugzilla.gnome.org/show_bug.cgi?id=711557
2013-11-07 12:41:27 -05:00
Ryan Lortie
c45b26d61f gio/Makefile: make sure to dist gappinfoprivate.h 2013-11-07 12:41:27 -05:00
Rico Tzschichholz
ffb39bff6f gio: Add gappinfoprivate.h to Makefile.am
In addition to e55d33edc1
2013-11-07 17:37:13 +01:00
Chun-wei Fan
87e6db8deb codegen.py: Rearrange GLib Version Check
...so that the generated code will build on all platforms, as compilers
like Visual C++ does not like #ifdef checks during a definition/use of
a macro.

https://bugzilla.gnome.org/show_bug.cgi?id=711049
2013-11-07 09:25:54 +08:00
Ryan Lortie
e55d33edc1 Add GAppInfoMonitor
This is a simple object that emits a "change" signal when the installed
applications may have changed in some way.

https://bugzilla.gnome.org/show_bug.cgi?id=711556
2013-11-06 11:26:53 -05:00
Ryan Lortie
86ce3bf48e gdesktopappinfo: keep a list of files in the dirs
In each DesktopFileDir, store a list of desktop files for that
directory.  This speeds up opening desktop files by name because we can
skip statting in directories that we know don't have the file and also
speeds up _get_all() because we can avoid enumeration.

This also improves our support for dealing with names like
'kde4/kate.desktop' (equivalent to kde4-kate.desktop) since we find out
about all of these files are the start and don't need to guess about
which '-' to change to a '/'.  It also means that we can easily deal
with more than one level of such prefixes.

We use a file monitor to watch for changes, invalidating our lists when
we notice them.

https://bugzilla.gnome.org/show_bug.cgi?id=711520
2013-11-06 10:56:25 -05:00
Chun-wei Fan
f493114280 gio/tests: Clean up inclusion of unistd.h
Include unistd.h only on *NIX and define items as necessary on Windows,
also replace instances of ssize_t with the GLib-equivilant gssize so to fix
the build on platforms that do not have ssize_t, such as Visual C++.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-04 22:55:30 +08:00
Chun-wei Fan
39a62a064b gio/test/resources.c: Fix for Windows
We need to use g_content_type_get_mime_type() to look up the mime type of
the file from the registry on the content type that was acquired on
Windows, as g_file_info_get_content_type() does not acquire the
file mime type (unlike on *NIX).

g_content_type_get_mime_type() on *NIX is more or less an no-op as it
simply returns the g_strdup()-ed version of the passed-in content type.

This will enable the resources test to pass on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=711047
2013-11-04 10:30:57 +08:00
Ross Lagerwall
89f9615835 gio: Don't allow skipping past the end of GLocalFileInputStream
The overridden implementation of the skip method for
GLocalFileInputStream allows skipping past the end of the file which is
inconsistent with the documentation.  Prevent this by first seeking to
the end of the file and then seeking backwards from there as much as
is necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=711048
2013-11-03 06:47:33 +02:00
Ross Lagerwall
e2fcb77cb0 gio: Clean up trashinfo file if trashing fails
https://bugzilla.gnome.org/show_bug.cgi?id=687202
2013-10-31 06:31:43 +02:00
Xavier Claessens
e94df7cfc2 Tests: It is useless to unset "DBUS_SESSION_BUS_ADDRESS" manually
If the goal is to make sure we don't have a dbus connection, it has
to call g_test_dbus_unset() instead which is much more complete.

In this case, g_test_dbus_unset() is called already, so it should be
fine.

https://bugzilla.gnome.org/show_bug.cgi?id=697348
2013-10-29 13:42:35 -04:00
Xavier Claessens
06fbdb04d5 GTestDBus: Make sure only DBUS_SESSION_BUS_ADDRESS is set by default
g_test_dbus_unset() now also unset DBUS_STARTER_ADDRESS and
DBUS_STARTER_BUS_TYPE.

https://bugzilla.gnome.org/show_bug.cgi?id=697348
2013-10-29 13:42:14 -04:00
Xavier Claessens
940fa98290 Tests: add session_bus_run() and use it where possible
This is to avoid having again the subtil bug in dbus-appinfo.c:
session_bus_down() was called before g_test_run() so the test was
running on the user's dbus session.

https://bugzilla.gnome.org/show_bug.cgi?id=697348
2013-10-29 13:30:22 -04:00
Colin Walters
5280c03368 tests/gdbus-introspection: Add a less trivial test case for _IGNORE_QUALIFIED
This is distilled from PackageKit which currently aborts on startup.

https://bugzilla.gnome.org/show_bug.cgi?id=665634
2013-10-29 09:37:06 -07:00
Lars Uebernickel
425f307b01 gtk-notification-backend: remove unused variable
A reference to the session bus is now stored in GNotificationBackend.
Remove the extraneous one in the gtk backend and stop using it in
withdraw_notification.

https://bugzilla.gnome.org/show_bug.cgi?id=711051
2013-10-29 09:01:35 -07:00
Ross Lagerwall
1a037b1408 gio: Clear error properly to prevent crash
https://bugzilla.gnome.org/show_bug.cgi?id=711070
2013-10-29 17:00:30 +02:00
Ryan Lortie
c8aba61713 GCancellable: drop lock for callback during connect()
Don't hold the lock when calling the user's callback during
g_cancellable_connect() for the case that the cancellable has already
fired.

Taken from a patch by Alex Larsson.

Doc updates from Colin Walters.

https://bugzilla.gnome.org/show_bug.cgi?id=705395
2013-10-29 10:49:48 -04:00
Chun-wei Fan
61e8e1cd02 gio/gsubprocess.c: Use g_snprintf()
snprintf() is unfortunately still not universally available, so use
g_snprintf() to ensure the build works on all platforms.

https://bugzilla.gnome.org/show_bug.cgi?id=711049
2013-10-29 22:44:11 +08:00
Ryan Lortie
b227528f32 GSettingsSchemaSource: fix parameter name in header
list_schemas() had the parameters called 'recursive' and 'non-recursive'
in the header instead of 'relocatable'.  Fix that.
2013-10-28 20:50:01 -07:00
Ryan Lortie
abb9a746f4 exporter: give error on Describe of missing action
If someone calls org.gtk.Actions.Describe on a non-existent action then
return an exception instead of a trivial description (disabled, no
state, etc.).

https://bugzilla.gnome.org/show_bug.cgi?id=687185
2013-10-28 18:11:46 -07:00
Ryan Lortie
e275b8bc6c exporter: give error on Describe of missing action
If someone calls org.gtk.Actions.Describe on a non-existent action then
return an exception instead of a trivial description (disabled, no
state, etc.).

https://bugzilla.gnome.org/show_bug.cgi?id=687185
2013-10-28 18:08:21 -07:00
Ryan Lortie
83869120bb GSimpleAction: don't allow changing state type
g_object_set() allowed us to bypass the usual checks that the state
doesn't change type and also leaked.

Fix that up by turning the state into a construct property (so that it
always gets set once during construction, even if only to NULL) and
then route the further sets through the C API so that they are subject
to the same checks.

https://bugzilla.gnome.org/show_bug.cgi?id=696424
2013-10-28 18:08:16 -07:00
Ryan Lortie
908d7d6d6a glib-compile-schemas: ignore qualified tags/attrs
Ignore qualified (in the XML namespace sense) tags and attributes when
compiling GSettings schemas.

This will allow people to add custom tags and attributes to their schemas
without tripping up the compiler.

https://bugzilla.gnome.org/show_bug.cgi?id=635641
2013-10-28 15:30:25 -07:00
Ryan Lortie
9933a9f904 GDBus: ignore qualified XML tags and attributes
Ignore qualified (in the XML namespace sense) tags and attributes when
parsing D-Bus introspection XML.

This will allow people to add custom tags and attributes to their D-Bus
interfaces without tripping up GDBus.

https://bugzilla.gnome.org/show_bug.cgi?id=665634
2013-10-28 15:28:51 -07:00
Ryan Lortie
0d89d38cac GSettings: fix for loop in 'extends' functionality
Obvious mistake :(
2013-10-28 12:10:13 -07:00
Ryan Lortie
b30486985b gsettings(1): stop using deprecated APIs
Stop using the recently-deprecated GSettings APIs.

Use the GSettingsSchema-based APIs instead.

This fixes a number of bugs and also a net reduction of code. In
particular, list-schemas will now work in context of a given --schemadir
argument.

https://bugzilla.gnome.org/show_bug.cgi?id=695558
2013-10-28 11:49:10 -07:00
Ryan Lortie
a1a4dbf6ff gsettings(1): use global variables
The number of arguments passed to each function is about to increase, so
just use global variables instead.

This is a commandline tool, after all...

https://bugzilla.gnome.org/show_bug.cgi?id=695558
2013-10-28 11:48:32 -07:00
Ryan Lortie
bcb030a474 GSettingsSchemaKey: add introspection APIs
Add g_settings_schema_has_key() and _get_range(), _range_check(),
_get_value_type(), _get_default_value() methods on GSettingsSchemaKey.

Deprecate the equivalent APIs on GSettings.

https://bugzilla.gnome.org/show_bug.cgi?id=683017
2013-10-28 11:31:48 -07:00
Ryan Lortie
bebdfb8e62 GSettings: add getters for user/default value
Add two new APIs: g_settings_get_user_value() and
g_settings_get_default_value().   Together, these should allow the
inspection of all interesting cases of "is this key set?" and "what
would happen if I reset this key?"

https://bugzilla.gnome.org/show_bug.cgi?id=668233
2013-10-28 10:19:49 -07:00
Ryan Lortie
2d06dbeef1 GSettings: small internal refactor
Add two boolean parameters to our internal getter utility function in
anticipation of the coming addition of g_settings_get_user_value() and
g_settings_get_default_value() APIs.

https://bugzilla.gnome.org/show_bug.cgi?id=668233
2013-10-28 10:19:49 -07:00
Ryan Lortie
84a6e651c2 GSettingsBackend: add read_user_value() API
This will get the 'user' value from the database (ie: the one that the user has
control over).

Provide a default implementation that chains to ->read().  That will work for
all of our internal backends which don't have a concept of layering or
lockdown.

The delayed backend implments "user value" by returning anything that's
in the changeset (incuding an explicit NULL) or chaining up otherwise.

We will use this for g_settings_get_user_value().

https://bugzilla.gnome.org/show_bug.cgi?id=668233
2013-10-28 10:19:49 -07:00
Philip Withnall
d567aa5114 gio: Remove an unused variable from Makefile.am
RESOLVER_LIBADD was not defined anywhere (its functionality has
migrated to NETWORK_LIBS instead).
2013-10-28 17:07:49 +00:00
Emmanuele Bassi
1b08980b48 gdbus-codegen: Take into consideration MAX_ALLOWED for private data
The G_ADD_PRIVATE() macro, and the auto-generated get_instance_private()
internal function, should be used conditionally depending on the maximum
allowed version of GLib, as defined by the GLIB_VERSION_MAX_ALLOWED
pre-processor symbol.

This allows generating code that can be compiled in projects that wish
to use an older API version of GLib through the use of the
GLIB_VERSION_MAX_ALLOWED symbol.

https://bugzilla.gnome.org/show_bug.cgi?id=710133
2013-10-28 12:47:16 -04:00
Ryan Lortie
066df98849 g_settings_schema_list: some fixes
Prevent a crash in the case that gvdb_table_list() returns NULL (ie:
because a schema has no keys).

Stop a memory leak caused by pointlessly stealing keys from a hashtable
(after we quarked them already).

Stop allocating an extra entry at the end of an array for a terminator
(that we never wrote anyway) when all functions using this API refer to
the out-parameter length array.

https://bugzilla.gnome.org/show_bug.cgi?id=711016
2013-10-28 09:44:05 -07:00
Matthias Clasen
5616e03f7a Fix handling of icons in GNotification
The fdo backend was sending a uri where a file path
was expected.
2013-10-28 12:32:04 -04:00
Stef Walter
65af7c47ff Add a request_certificate virtual method to GTlsInteraction
This allows GTlsConnection implementations to request a certificate
from the user.

Fix ups by Dan Winship <danw@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=637257
2013-10-28 09:36:26 +01:00
Matthew Barnes
1fba61981a GKeyFileSettingsBackend: ignore file deletions
Ignore the keyfile being deleted (ie: by the user) instead of reporting
it to the application as all values being reverted back to their
originals.

https://bugzilla.gnome.org/show_bug.cgi?id=637956
2013-10-27 17:27:44 -07:00
Christian Persch
ef57996f44 Add test for extended schemas
The test checks that the keys of the base schema are all present in
the extended schema.

https://bugzilla.gnome.org/show_bug.cgi?id=645453
2013-10-27 17:23:17 -07:00
Ryan Lortie
cbf8cf8598 GSettings: properly support 'extends'
Support the 'extends' attribute that has been supported by the compiler
for a long time by doing three things:

 - when creating a schema that extends another schema, lookup that other
   schema

 - when looking up keys and we can't find them in the schema, check
   (recursively) in the 'extends' schema

 - when listing all keys in a schema, also visit the extends schemas,
   but take care to avoid duplicates caused by overrides

Extend the testsuite to verify that it works.

https://bugzilla.gnome.org/show_bug.cgi?id=645453
2013-10-27 17:18:10 -07:00
Ross Lagerwall
3041d0a8db gio: Fix typo in documentation
https://bugzilla.gnome.org/show_bug.cgi?id=710859
2013-10-27 17:15:38 -07:00
Ryan Lortie
6f386341bd Add g_settings_schema_source_list_schemas()
g_settings_list_schemas() and g_settings_list_relocatable_schemas() are
now deprecated.

This will allow listing off schemas on non-default sources and is a
better fit with the new direction the API is going.

https://bugzilla.gnome.org/show_bug.cgi?id=680838
2013-10-27 17:12:57 -07:00
Colin Walters
13067362d2 gsubprocess: Add documentation about default input directions 2013-10-27 16:02:36 -04:00
Colin Walters
6bb9d17e40 gsubprocess: Fall back to plain F_DUPFD+fcntl for OS X <= Snow Lion
Since it apparently doesn't have F_DUPFD_CLOEXEC.

https://bugzilla.gnome.org/show_bug.cgi?id=710962
2013-10-27 16:02:36 -04:00
Ryan Lortie
00b35c78f8 Add a testcase for summary/description
https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 10:42:55 -07:00
Ryan Lortie
96a053e025 Add g_settings_schema_key_get_summary/description
Add an API to read the summary and description from the .xml schema
files.

This will be used by dconf-editor and gnome-tweak-tool.

This API is a bit heavy -- it parses the XML and builds a table.  It
also loads gettext domains for translation.  It only does these things
if it is used, however, so it will not impact normal applications.

We store the summary/description in a pair of hash tables on the schema
source (which we have a backref to as of a few commits ago).  We can't
use a global table because people might want to request summary and
description from non-default sources.  We don't want to use per-schema
tables because we'd have to reparse the directory every time (since we
cannot guess which file a schema may have been in).

https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 10:42:55 -07:00
Ryan Lortie
84fa07aeb1 Make GSettingsSchemaKey public
Take this private API and make it public along with a boxed type and
ref/unref functions.

Future commits will add accessors with new functionality and some that
allow us to deprecate functions on GSettings itself (such as
g_settings_get_range).

https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 10:42:50 -07:00
Ryan Lortie
0ef43ba743 GSettingsSchema: store a backref to the source
Record in each GSettingsSchema object the source from which it came.

This will be useful in future commits.

https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 09:32:10 -07:00
Ryan Lortie
e462eda3d5 Clean up GSettingsSchema logic
The way we created the global schema list predates
g_settings_schema_source_new_from_directory() and therefore doesn't use
it.

Update it to use that function, removing some code.

https://bugzilla.gnome.org/show_bug.cgi?id=668232
2013-10-27 09:32:10 -07:00
Giovanni Campagna
415c6d2e27 gapplication: don't emit warnings for DBus calls
If a broken (or malicious) remote client calls Open or CommandLine
on a GApplication that does not implement those, return a DBus
error instead of going through and then emitting a warning.

https://bugzilla.gnome.org/show_bug.cgi?id=710885
2013-10-26 14:55:18 +02:00
Giovanni Campagna
3e48e3be40 gapplication: fix memory leak
g_variant_get_child_value() returns a new GVariant, which we must
free.

https://bugzilla.gnome.org/show_bug.cgi?id=710885
2013-10-26 14:55:18 +02:00
Philip Withnall
fcd2f7e639 tests: Add tests for the thumbnail verification code in GIO
This code was added for use by the G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID
file attribute, but may end up being used elsewhere (e.g. in GVfs) as well.
As it’s dealing with untrusted external files, and the non-trivial PNG file
format, this commit adds several test cases to cover valid and invalid PNG
files.

The security model for the thumbnail verification code is that the user’s
cache directory is untrusted, and potentially any PNG file which is passed
to the verifier has been manipulated arbitrarily by an attacker.

This is a follow-up to commit fe7069749f.

https://bugzilla.gnome.org/show_bug.cgi?id=709898
2013-10-24 13:55:33 -04:00
Colin Walters
ed6ca39d3b Revert "Use g_return_val_if_fail() for developer-only messages"
This reverts commit 00f0795a84.

https://bugzilla.gnome.org/show_bug.cgi?id=569017
2013-10-24 09:53:55 -04:00
Jiro Matsuzawa
d5e2a57741 gsettings-tool: Add --version into general usage
https://bugzilla.gnome.org/show_bug.cgi?id=707002
2013-10-24 09:53:55 -04:00
Ryan Lortie
6568843624 GSettings: verify path validity on constructors
Don't allow constructing GSettings objects with invalid paths.

https://bugzilla.gnome.org/show_bug.cgi?id=704802
2013-10-24 09:53:55 -04:00
Olivier Brunel
0a7d1084a5 gthemedicon: Fallback to non-symbolic icons
When doing fallback for symbolic icons, we first shorten the name at dashes
while preserving the -symbolic suffix. But after exhausting that, we should also
try stripping the suffix.

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

Signed-off-by: Olivier Brunel <jjk@jjacky.com>

https://bugzilla.gnome.org/show_bug.cgi?id=710254
2013-10-24 08:09:48 -04:00
Philip Withnall
856d901569 gdbus: Ensure message matching always succeeds against path_namespace='/'
This copies the fix from upstream D-Bus bug
https://bugs.freedesktop.org/show_bug.cgi?id=70799 to the GDBusDaemon
implementation, ensuring that matching against path_namespace='/' succeeds
for all keys (i.e. it’s a no-op).

https://bugzilla.gnome.org/show_bug.cgi?id=710726
2013-10-23 20:55:00 +01:00
Ryan Lortie
fe7069749f file-info: Add a G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID attribute
This indicates whether the thumbnail (given by G_FILE_ATTRIBUTE_THUMBNAIL_PATH)
is valid — i.e. to represent the file in its current state. If
G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID is FALSE (for a normal _or_ failed
thumbnail) it means the file has changed since the thumbnail was generated, and
the thumbnail is out of date.

Part of checking thumbnail validity (by the spec) involves parsing
headers out of the thumbnail .png so we include some (small) code to do
that in a separate file.  We will likely want to copy this code to gvfs
to do the same for GVfsFile.

Heavily based on a patch from Philip Withnall <philip.withnall@collabora.co.uk>
who suggested the feature and designed the API.

https://bugzilla.gnome.org/show_bug.cgi?id=709898
2013-10-23 11:56:28 -04:00
Ryan Lortie
38dc8d4cd3 GMemoryOutputStream: docs and whitespace fixes
Document the difference between resizable and fixed-sized streams,
particularly with regards to sizing and seeking.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:32:13 -04:00
Ryan Lortie
1d1c17d9ee GMemoryOutputStream: improve seek tests
Improve test coverage for testing seeking on fixed vs. resizable
GMemoryOutputStream.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:32:13 -04:00
Ryan Lortie
fdc5cd8d9f Change semantics of seek on memory output stream
It is our intention that memory output streams should operate in two
distinct modes, depending on if a realloc function was provided or not.

In the case that we have a realloc function (resizable mode), we want
the stream to behave as if it were a file that started out empty.  In
the case that we don't have a realloc function (fixed-sized mode), we
want the stream to behave as a block device would.

To this end, we introduce two changes in functionality:

 - seeking to SEEK_END on a resizable stream will now seek to the end of
   the valid data region, not to the end of the allocated memory (which
   is really just an implementation detail)

 - seeks past the end of the allocated memory size are now permitted,
   but only on resizable streams.  The next write will grow the buffer
   (inserting zeros between).

Some tweaks to testcases were required in order not to break the build,
which indicates that this is an API break, but it seems unlikely that
anyone will be effected by these changes 'in the real world'.

Updates to documentation and further testcases are in following commits.

Based on a patch from Maciej Piechotka <uzytkownik2@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:31:27 -04:00
Ryan Lortie
38ef509cf3 GSeekable: document seek-past-end semantics
Introduce the concept of "fixed" vs. "resizable" streams and document
how g_seekable_seek() works for each case.

We don't include g_seekable_is_fixed_size() at this point because we
don't know if anyone would require it.  This may appear in the future if
someone asks for it, however.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
2013-10-23 11:19:27 -04:00
Philip Withnall
3b28df1e00 gdbus: Work around a D-Bus bug with path_namespace='/' match rules
D-Bus versions < 1.6.18 (i.e. all current versions) have a bug with the
path_namespace='/' match rule key. It should conceptually match everything,
but actually matches nothing. This results in no property change (or other)
signals being forwarded to the D-Bus client.

The work-around implemented in GDBusObjectManagerClient is to remove the
path_namespace match key if its value is ‘/’.

For the upstream D-Bus bug, see:
https://bugs.freedesktop.org/show_bug.cgi?id=70799

https://bugzilla.gnome.org/show_bug.cgi?id=710726
2013-10-23 15:36:23 +01:00
Matthias Clasen
a7bd6c47db Clarify the g_application_withdraw_notification docs
Mention that notifications are dismissed when activated.
2013-10-21 18:46:48 -04:00
Ryan Lortie
1f0e69f734 Don't build gapplication(1) on win32
It's pretty closely tied to desktop files...
2013-10-21 15:24:55 -04:00
Ryan Lortie
358588ed2a GSubprocess win32 fixups
Note: we go out of our way not to pass a child setup function on win32
(even if it does nothing) because we get a g_warning() from gspawn if we
do so.
2013-10-21 15:24:55 -04:00
Colin Walters
b21c86b6a0 GNotification: Don't install private headers, avoid duplicated prototype
These both break gobject-introspection's build, and moreover are
things we don't want to do anyways.
2013-10-21 15:05:45 -04:00
Ryan Lortie
6957004007 GNotification: finish documentation
Add the missing documentation and add the section to the GIO reference
docs.  Fix up a few small documentation issues.

https://bugzilla.gnome.org/show_bug.cgi?id=688492
2013-10-21 14:30:30 -04:00
Ryan Lortie
51fac60a92 GNotification: some final cleanups
Move a method from GNotificationBackend into the fdo backend (since it
was only used from here).  Remove the accessors for the already-public
(in private header) ->dbus_connect and ->application on
GNotificationBackend.

https://bugzilla.gnome.org/show_bug.cgi?id=688492
2013-10-21 14:30:30 -04:00
Lars Uebernickel
766f5584ce Add gtk notification backend
https://bugzilla.gnome.org/show_bug.cgi?id=688492
2013-10-21 14:30:26 -04:00
Lars Uebernickel
639bd3626b Add GNotification
https://bugzilla.gnome.org/show_bug.cgi?id=688492
2013-10-21 14:30:26 -04:00
Djalal Harouni
d308ede491 gio/gbufferedinputstream: fix redundant-decls of g_buffered_input_stream_finalize()
g_buffered_input_stream_finalize() is already declared as static in this
gbufferedinputstream.c file, so just remove the redundant declaration.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>

https://bugzilla.gnome.org/show_bug.cgi?id=710345
2013-10-19 12:18:55 -04:00
Matthias Clasen
c848323948 Fix up subprocess docs
The GSubprocessLauncher docs had their own long description,
but were not properly set up as their own section.
2013-10-17 20:55:53 -04:00
Matthias Clasen
8520c9cdf4 Add some missing argument docs 2013-10-17 20:37:57 -04:00
Colin Walters
ebd098155b tests/gsubprocess: Locate test child binary for installed tests too
Just use the new g_test_build_filename() rather than assuming
it's in cwd.
2013-10-17 22:39:48 +01:00
Ihar Hrachyshka
00f0795a84 Use g_return_val_if_fail() for developer-only messages
Replaced several usages of GError with g_return_val_if_fail() for
developer-only messages. As additional value, it also removes those
messages from the list to translate, simplifying translator's work a
bit.

https://bugzilla.gnome.org/show_bug.cgi?id=569017
2013-10-17 15:11:51 -04:00
Ryan Lortie
542ad4db03 Fixup GSubprocess documentation bits 2013-10-17 15:01:42 -04:00
Colin Walters
9318d5a429 gsubprocess: Add UTF-8 variants of communicate()
Over many years of writing code interacting with subprocesses, a pattern
that comes up a lot is to run a child and get its output as UTF-8, to
put inside a JSON document or render in a GtkTextBuffer, etc.

It's very important to validate at the boundaries, and not say deep
inside Pango.

We could do this a bit more efficiently if done in a streaming fashion,
but realistically this should be OK for now.
2013-10-17 14:32:44 -04:00
Colin Walters
0e1a3ee345 gsubprocess: Fix up communicate
We weren't closing the streams after we were done reading or writing,
which is kind of essential.  The easy way to fix this is to just use
g_output_stream_splice() to a GMemoryOutputStream rather than
hand-rolling it.  This results in a substantial reduction of code
complexity.

A second serious issue is that we were marking the task as complete when
the process exits, but that's racy - there could still be data to read
from stdout.  Fix this by just refcounting outstanding operations.

This code, not surprisingly, looks a lot like the "multi" test.

Next, because processes output binary data, I'd be forced to annotate
the char*/length pairs as (array) (element-type uint8).  But rather than
doing that, it's *far* simpler to just use GBytes.

We need a version of this that actually validates as UTF-8, that will be
in the next patch.
2013-10-17 14:32:44 -04:00
Colin Walters
5b48dc40cc GSubprocess: New class for spawning child processes
There are a number of nice things this class brings:

0) Has a race-free termination API on all platforms (on UNIX, calls to
   kill() and waitpid() are coordinated as not to cause problems).
1) Operates in terms of G{Input,Output}Stream, not file descriptors
2) Standard GIO-style async API for wait() with cancellation
3) Makes some simple cases easy, like synchronously spawning a
   process with an argument list
4) Makes hard cases possible, like asynchronously running a process
   with stdout/stderr merged, output directly to a file path

Much rewriting and code review from Ryan Lortie <desrt@desrt.ca>

https://bugzilla.gnome.org/show_bug.cgi?id=672102
2013-10-17 14:32:44 -04:00
Colin Walters
c515c3ed11 gio: Add private API to create win32 streams from fds
This will be used by GSubprocess.

https://bugzilla.gnome.org/show_bug.cgi?id=672102
2013-10-17 14:27:07 -04:00
Jasper St. Pierre
a2f6f0d2f6 gtask: Fix invalid name in documentation 2013-10-17 13:04:06 -04:00
Ryan Lortie
9defb6b1b1 New gapplication(1) tool
This is essentially a commandline implementation of the client-side of
the org.freedesktop.Application D-Bus interface.

It includes support for tab-completion based on desktop files and their
contents.

https://bugzilla.gnome.org/show_bug.cgi?id=704218
2013-10-17 10:12:27 -04:00
Ryan Lortie
4e1e36a7f0 Revert "gapplication: don't rely on cmdline being finalized immediately"
This reverts commit c5748328be.
2013-10-17 08:22:11 -04:00
Cosimo Cecchi
c5748328be gapplication: don't rely on cmdline being finalized immediately
The GApplicationCommandLine DBus implementation currently calls
g_dbus_method_invocation_return_value() in its finalize() implementation
only, relying on the object being destroyed after g_object_unref() is
called on it inside g_application_impl_method_call().

While this is usually fine for C applications, when overriding the
command_line vfunc from language bindings, the binding might add extra
references to the object, which might not be released immediately - e.g.
because they're garbage collected, or possibly even leaked. The same
scenario could happen in a C application that decides to keep a
reference to the passed-in GApplicationCommandLine object.

To ensure the CommandLine DBus method always gets a reply after the
invocation of command_line in the primary instance, explicitly send the
message back before dropping our reference to the object.

https://bugzilla.gnome.org/show_bug.cgi?id=708042
2013-10-16 23:06:13 -04:00
Colin Walters
be2656f139 g_file_copy: Fall back to pathname queryinfo to help gvfs backends
It's not difficult to do; not all backends implement it, and for some
it may be difficult to implement query_info_on_read(), so let's just
do both.

https://bugzilla.gnome.org/show_bug.cgi?id=706254
2013-10-16 13:33:14 -04:00
Colin Walters
e2d5282636 GMemoryOutputStream: Don't return -1 as a gboolean in precondition
Since it could confuse callers (admittedly who are already violating
a precondition).

Just spotted while adapting some bits of this code for a ssh library.
2013-10-08 12:19:11 -04:00
Kalev Lember
be7f40185f xdgmime: Fix an invalid read
This commit factors out a function for comparing string suffixes, and at
the same time makes it safe for mime types that are shorter than the
"/*" suffix.

==25418== Invalid read of size 1
==25418==    at 0x3C6D0F9D22: __gio_xdg_cache_mime_type_subclass (xdgmimecache.c:848)
==25418==    by 0x3C6D09ED8C: g_content_type_is_a (gcontenttype.c:158)
==25418==    by 0x34D8031E95: gtk_recent_filter_filter (gtkrecentfilter.c:733)
==25418==    by 0x34D802F167: _gtk_recent_chooser_get_items (gtkrecentchooserutils.c:387)
==25418==    by 0x34D802D07F: idle_populate_func (gtkrecentchoosermenu.c:1011)
==25418==    by 0x34D7A20477: gdk_threads_dispatch (gdk.c:804)
==25418==    by 0x3C6C0492F5: g_main_context_dispatch (gmain.c:3065)
==25418==    by 0x3C6C049677: g_main_context_iterate.isra.23 (gmain.c:3712)
==25418==    by 0x3C6C04972B: g_main_context_iteration (gmain.c:3773)
==25418==    by 0x34D7FC2AF4: gtk_main_iteration (gtkmain.c:1262)
==25418==    by 0x408EB4: main (in /usr/bin/glade)

https://bugzilla.gnome.org/show_bug.cgi?id=708529
2013-10-04 22:08:36 +02:00
Ryan Lortie
e0ffd5c184 appinfo: Don't try DBusActivatable with load_from_keyfile
We can't get the name of the filename, so we can't determine the application
ID.  We'll have to fallback on Exec= for this case.

https://bugzilla.gnome.org/show_bug.cgi?id=709326
2013-10-04 12:19:03 -04:00
Dan Winship
5a269e5a90 gcredentials: add Solaris support
Based on patches from Igor Pashev.

https://bugzilla.gnome.org/show_bug.cgi?id=705029
2013-10-04 09:51:31 -04:00
Dan Winship
66edac7fb9 gcredentials: add Hurd support
It uses the same system as FreeBSD.

https://bugzilla.gnome.org/show_bug.cgi?id=708265
2013-10-04 09:51:31 -04:00
Dan Winship
cedd697bf8 gcredentials: add internal macros to simplify all the #ifdefs
Rather than having lots of obscure platform-based #ifdefs all over
gio, define some macros in gcredentialsprivate.h, and use those to
simplify the rest of the code.

https://bugzilla.gnome.org/show_bug.cgi?id=701482
2013-10-04 09:51:31 -04:00
Giovanni Campagna
32d2539295 GDBusProxy: add flag to control autostarting at construction time
Sometimes the application doesn't want to autostart a service
when it creates a proxy, but wants the service autostarted when
it makes the first method call. Allow that behavior with a new
flag.

https://bugzilla.gnome.org/show_bug.cgi?id=708828
2013-10-04 02:38:17 +02:00
Ryan Lortie
c8e1dbb106 gdesktopappinfo: Large-scale whitespace fixup
Fix up a lot of whitespace issues in this file since we're about to do
some pretty serious rewriting here anyway...

Add some fold markers while we're at it.
2013-10-03 10:40:25 -04:00
Ryan Lortie
b0601e7558 gdesktopappinfo: rework search path
Change the search path to be a global array of 'DesktopFileDir' structures and
change the 'get' function to an 'ensure' function.

This is just a straight-up refactor.  Future patches will expand the
DesktopFileDir structure.
2013-10-03 10:40:25 -04:00
Ryan Lortie
5e59ab8e8c gdesktopappinfo: remove global_defaults_cache
...and some related functions.

This variable is also used for nothing at all.
2013-10-03 10:40:25 -04:00
Ryan Lortie
b95ef4aad4 gdesktopappinfo: remove should_ping_mime_monitor
This variable is used for nothing...
2013-10-03 10:40:25 -04:00
Ryan Lortie
33762a4173 glocalfile: add private worker monitor APIs
Add a convenient and race-free method of watching local files from the
GLib worker thread.

Without this, the race-free way to create a monitor that dispatches
events to the worker thread looked something like this:

 - dispatch an idle to the worker thread
 - from the idle, create the monitor and connect signals
 - from the original thread, wait (on a cond?) until the worker thread
   has finished setting up the monitor
 - read the file that you were monitoring

which is just ridiculously complicated...

To use the new API:

  monitor = g_local_file_monitor_new_in_worker ("/path/to/some/file",
                                                G_FILE_MONITOR_NONE,
                                                &error);
  g_assert_no_error (error);

  g_signal_connect (monitor, "changed", G_CALLBACK (callback), NULL);

  g_local_file_monitor_start (monitor);

'callback' will run from the GLib worker thread.

This is the reason that the start() call was introduced in the previous
commit.  The backends that don't use the start() call will have a very
thin race between creating the monitor and connecting the signal, but
hopefully they will be fixed soon.

These new APIs will be used (at least) from gdesktopappinfo to watch for
changes in the desktop file directories.

https://bugzilla.gnome.org/show_bug.cgi?id=704887
2013-10-03 10:37:47 -04:00
Ryan Lortie
5409d7827e GFileMonitor: support specifying a context
Add a new "context" construct-only property to allow explicitly
specifying the context in which events should be dispatched.

https://bugzilla.gnome.org/show_bug.cgi?id=704887
2013-10-03 10:37:35 -04:00
Ryan Lortie
700677de51 inotify: stop using constructor()
and start using the new start() vcall on the local monitor classes.

I only port inotify because I am uncomfortable making changes to the
other monitor backends without having a way of testing them.

https://bugzilla.gnome.org/show_bug.cgi?id=704887
2013-10-03 10:37:30 -04:00
Ryan Lortie
b050dc3c0a local monitors: make more idiomatic use of GObject
Stop abusing constructor() to do startup work, adding _start() calls
instead.

The backends themselves still use constructor() although a patch will be
following to also fix inotify.

The reason for using a separate start() call instead of constructed()
will become apparent in future commits.

https://bugzilla.gnome.org/show_bug.cgi?id=704887
2013-10-03 10:37:19 -04:00
Ryan Lortie
1ddfd9d98e directory monitor: use the right 'mount_notify'
During initialisation of a directory monitor with the
G_FILE_MONITOR_WATCH_MOUNTS flag set, GLocalDirectory monitor will add a
UNIX mount watch in case the file notification backend doesn't support
reporting these events for itself.

Unfortunately, it was performing the check incorrectly, resulting in a
monitor always being added.

Fix that, and add the #define for G_LOCAL_DIRECTORY_MONITOR_GET_CLASS()
that was also missing (since the fix depends on it).

https://bugzilla.gnome.org/show_bug.cgi?id=704882
2013-10-03 10:35:22 -04:00
Colin Walters
dd4c3695b4 goutputstream: Add clear warning about short writes to _write_bytes() and async version
Matthew Barnes noted this on IRC a few days ago.  I just had this file
open for other reasons and decided to tweak the docs to make this trap
more clear.

https://bugzilla.gnome.org/show_bug.cgi?id=709301
2013-10-02 11:23:01 -04:00
Ryan Lortie
27898916d4 g_settings_list_children: only list viable schemas
Don't return children with invalid schemas from
g_settings_list_children() (ie: missing schemas or mismatched paths).
This prevents gsettings list-recursively from crashing when broken
schemas are installed on the system.

https://bugzilla.gnome.org/show_bug.cgi?id=705688
2013-10-02 12:37:09 -04:00
Michael Forney
75bb906e5e Add missing string.h include
Required for memset()
2013-10-01 09:00:10 -04:00
Mike Ruprecht
4e9e7d0cba GOutputStream: Use async read/write of streams in splice_async()
There are some corner cases where using the sync version of read/write
in a thread could cause thread-safety issues. In these cases it's
possible to override the output stream's splice_async() function,
but for input streams one would need to do some acrobatics to
stay thread-safe. Alternatively, some implementations may not even
override their sync read/write functions.

This patch refactors the default splice_async() implementation to
call the sync read and write functions in a thread only when both
async versions are thread-based. When one or both are non-threaded,
it calls the virtual write_async() and read_async() functions of the
involved streams within the same thread.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
87e5617a65 GOutputStream: Split _close_async for internal use
Refactor g_output_stream_close_async() into itself and an internal
variant for potential use inside other operations (splice_async).
The internal version must be called between
g_output_stream_set_pending() and g_output_stream_clear_pending().

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
416ca8ad57 GOutputStream: Rename _g_output_stream_close_internal() for consistency
https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:41 -04:00
Mike Ruprecht
e967a76728 tests: Add testcases for g_output_stream_splice_async()
Previously, no testcases tested the close flags of
g_output_stream_splice_async. This patch adds tests for that and
also tests various combinations of threaded and non-threaded
GInputStream async reads and GOutputStream async writes.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:40 -04:00
Mike Ruprecht
dec3bfeebc GOutputStream: Add g_output_stream_async_write_is_via_threads()
In implementing a better g_output_stream_splice_async() and possibly
other situtations it's helpful to know whether the output stream's
write function internally uses threads. If it and the input stream's
read async functions use threads, then the splice function could
spawn a single thread for better efficiency.

This patch adds a function to determine whether an output stream's
g_output_stream_write_async() function internally uses threads.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:40 -04:00
Mike Ruprecht
94a232a4ed GInputStream: Add g_input_stream_async_read_is_via_threads()
In implementing a better g_output_stream_splice_async() and possibly
other situtations it's helpful to know whether the input stream's
read function internally uses threads. If it and the output stream's
write async functions use threads, then the splice function could
spawn a single thread for better efficiency.

This patch adds a function to determine whether an input stream's
g_input_stream_read_async() function internally uses threads.

https://bugzilla.gnome.org/show_bug.cgi?id=691581
2013-09-29 17:48:40 -04:00
John Ralls
ab5aa2aa3a Fix the -Werror=format-nonliteral fixes for older GCCs
They don't allow that pragma inside functions.
2013-09-29 11:33:30 -07:00
John Ralls
09d83640a8 More -Werror=format-nonliteral fixes
This fixes the build with CLang.

https://bugzilla.gnome.org/show_bug.cgi?id=702516
2013-09-29 11:03:16 -04:00
Dan Winship
4a953af8a5 gio: make gnetworking.h nodist
https://bugzilla.gnome.org/show_bug.cgi?id=708972
2013-09-28 12:18:14 -04:00
Bastien Nocera
2d8e5ef81e gdesktopappinfo: Call g_file_get_path() on demand
Rather than always calling out to g_file_get_path() (which
might block, whatever the documentation might say), postpone
the call until we actually need it.

https://bugzilla.gnome.org/show_bug.cgi?id=708753
2013-09-27 09:52:57 +02:00
Robert Ancell
458c1c0f16 gio: Fix documentation for GSocketControlMessage that refers to a 'file description' instead of a 'file descriptor' 2013-09-27 14:52:51 +12:00
Jan Schmidt
0167c3340d gio: Fix -Werror format string errors from mismatched ints. 2013-09-27 10:52:50 +10:00
William Orr
7eb1e5fc5b glocalfile: Only use O_DIRECTORY if available
Solaris 10 for example doesn't have it.

https://bugzilla.gnome.org/show_bug.cgi?id=708860
2013-09-26 15:22:51 -04:00
James Strandboge
74314de4d8 gio: Fix typo in the /org/freedesktop/DBus path
https://bugzilla.gnome.org/show_bug.cgi?id=708677
2013-09-24 09:25:51 -04:00
Svante Signell
1d4bb3f5d0 gio/gsocket.c: Fix error code checks when SOCK_CLOEXEC is defined but
not supported on GNU/Hurd.

https://bugzilla.gnome.org/show_bug.cgi?id=708266
2013-09-24 08:59:38 -04:00
Ryan Lortie
abf505fd0e More gio-du win32 fixes
Don't free the utf8 filename before the async function completes.

also, gitignore
2013-09-23 16:31:40 -04:00
Ryan Lortie
6d08d1191b Revert "gcancellable: allow g_cancellable_disconnect from "cancelled" handler on same thread"
This reverts commits 83605e2d0a and
140fa7ee46.
2013-09-23 16:15:52 -04:00
Alexander Larsson
140fa7ee46 cancellable: Minor fix to docs
The code uses "my_data", not "data" everywhere else.
2013-09-23 09:11:04 +02:00
Ray Strode
83605e2d0a gcancellable: allow g_cancellable_disconnect from "cancelled" handler on same thread
g_cancellable_disconnect will wait until any pending "cancelled"
handlers finish.  This is useful because disconnecting a handler can have the
side-effect of freeing data that the cancelled handler may rely on.
Unfortunately, the code used to enforce this synchronization between
"cancelled" handlers and g_cancellable_disconnect will also cause
deadlock if the cancelled handler itself calls g_cancellable_disconect.

Obviously, if g_cancellable_disconnect is explicitly called by a "cancelled"
handler, then the "cancelled" handler is shouldering the responsibility
of not using any data that may be freed by disconnection.

Also, g_cancellable_disconnect can be called in unexpected places by
lower layers in the code (for instance as a result of g_source_destroy).
In practice, this means it's easy for deadlocks to inadvertently crop
up when using "cancelled" handlers.

For these reasons, it would be good to fix the deadlock.

This commit prevents the deadlock by allowing foregoing synchronization,
if a pending "cancelled" handler is in the same thread as the
g_cancellabale_disconnnect call.

https://bugzilla.gnome.org/show_bug.cgi?id=705395
2013-09-23 09:09:48 +02:00
Murray Cumming
e31ce1cfe3 gsettings: Correct a GLIB_AVAILABLE_IN_* 2013-09-20 09:27:53 +02:00
Ryan Lortie
b72c466653 measure_disk_usage: properly report results
In the async case, make sure we copy all of the out parameters from the
results structure, not just 'disk_usage'.
2013-09-17 09:53:18 -04:00
Ryan Lortie
dbf95a5ae9 measure_disk_usage: skip progress on NULL callback
In the real_..._async wrapper for GFile.measure_disk_usage, skip the
wrapping of the progress callback in the case that the user gave a NULL
callback to the async function.  This is a performance improvement
because the sync version won't have to do continuous sampling of the
clock to issue a call to the wrapper which will then do nothing.

Unfortunately, I made this simplifying assumption when writing the
wrapper, but forgot to actually implement it when making the sync call.
As a result, the wrapper is still called, and invokes the NULL callback,
causing a segfault.

Make sure we pass NULL if the user's callback was NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-17 09:44:23 -04:00
Ryan Lortie
348764269d gio-du: show the correct filename in progress
We were showing argv[1] in the progress output before, which is not
always the filename.
2013-09-16 13:42:02 -04:00
Chun-wei Fan
2684dec447 gio-du: Improve test program on Windows
Make use of __wgetmainargs() on Windows so that we can get wide char
versions of the argv's that are passed in when this test program is being
invoked.  This is necessary as one might enter non-ASCII, such as
CJK characters filenames and/or directories to run the test program
against, so that we can process the name(s) and pass the proper
UTF-8-encoded name(s) of the files/directories that is being tested.

https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-16 13:40:14 -04:00
Ryan Lortie
084e5b0122 GLocalFile: use GDir for g_file_measure_disk_usage
It turns out that although dirent is available on mingw32 (where the
code was originally tested), it is not usable from MSVC.

Avoid portability problems by just using GDir.

Also, be careful about ensuring that we utf8-format filenames in our
error messages, and leave out the "file://" component since the strings
we're displaying are not URIs (and we don't want to make them URIs since
the extra escaping would reduce legibility).

Thanks to Chun-wei Fan <fanchunwei@src.gnome.org> for portions of this
patch and for reviews.

https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-16 13:38:40 -04:00
Chun-wei Fan
7a91a6c9a5 gio/tests/gio-du.c: Avoid Using Unintialized Variable
https://bugzilla.gnome.org/show_bug.cgi?id=707787
2013-09-13 11:31:05 +08:00
Ryan Lortie
5a11019034 tests: remove assertion for '!uncertain' on .txt
Virtaal installs a mime package for various .po-like file formats, one
of which has the extension .txt.  This causes GLib to report ".txt"
files still as "text/plain" but no longer with complete certainty.

The result is that asserting !uncertain during the testsuite causes the
test to fail if Virtaal happens to be installed.

Remove this assertion.
2013-09-12 14:40:24 -04:00
Dieter Verfaillie
49bbebc0b9 gio/tests/network-address: fix SCOPE_ID_TEST_INDEX fallback 2013-09-09 23:57:30 +02:00
Ryan Lortie
a61c9f489a tests/: add gio-du
This is basically a minimally-featured 'du' equivalent to manually test
g_file_measure_disk_usage().

https://bugzilla.gnome.org/show_bug.cgi?id=704893
2013-09-09 10:41:17 -04:00
Ryan Lortie
6ec2bb17c3 GFile: add new g_file_measure_disk_usage() API
This is essentially the equivalent of 'du'.

This is currently only supported on local files.  gvfs will add support for the
interface later.

https://bugzilla.gnome.org/show_bug.cgi?id=704893
2013-09-06 13:16:17 -04:00
Dan Winship
cde9f4598b gio/tests/socket: fix warning building on win32
setsockopt() has a broken prototype on win32. Fix this by just using
g_socket_set_option() instead.
2013-08-31 11:40:44 -04:00
Sebastian Dröge
02393e6faf gio/tests/socket: add test for g_socket_get_available_bytes()
https://bugzilla.gnome.org/show_bug.cgi?id=686786
2013-08-31 11:40:44 -04:00
Dan Winship
9fd0927e58 gsocket: Fix g_socket_get_available_bytes() on Windows and OS X
On Windows and OS X, FIONREAD on a UDP socket gets the total number of
bytes available, not the number of bytes available in the next packet,
which is the more useful number (and how the function always behaved
on Linux).

On OS X, fix this by using SO_NREAD. On Windows, fix this by doing a
MSG_PEEK recv() into a giant buffer, since there is apparently no
other way to get the information.

https://bugzilla.gnome.org/show_bug.cgi?id=686786
2013-08-31 11:40:44 -04:00
Dan Winship
11254b3c7d gsocket: make GSocketSource trigger on G_IO_NVAL
Getting G_IO_NVAL probably indicates bugs/race conditions in the
calling code, but if GSocket just ignores it, it will get stuck in an
infinite loop.
2013-08-29 09:25:42 -04:00
Jonas Danielsson
666b0bed9c gloadableicon: Fix gir bindings for load_finish
Make the gir notation for g_loadable_icon_load_finish match
the ones for g_loadable_icon_load.

https://bugzilla.gnome.org/show_bug.cgi?id=706706
2013-08-24 08:53:30 -04:00
Sebastian Dröge
ab6b7dbc2e GSocket – GSocketSource finalizing not threadsafe on Windows
The requested_conditions list access is not threadsafe. When passing
the socket ownership from a GSource callback to another thread, which
also creates a GSocketSource for the socket, it can happen that the
original GSocketSource is finalized at the same time as the new one
is created. This would cause inconsistencies in the requested_conditions
list and can cause assertions or completely undefined behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=705027
2013-08-22 16:14:56 +02:00
Chun-wei Fan
bb7b0a8ca0 gio/gdbusaddress.c: Silence RunDLL errors
The RunDLL command call during get_session_address_dbus_launch() was
expecting _g_win32_run_session_bus@16 and g_win32_run_session_bus
on Win32 and Win64 respectively at least when GLib is compiled with MSVC,
not g_win32_run_session_bus@16, which caused annoying RunDLL error dialogue
boxes to show up during the use of GtkApplication (such as when running
gtk3-demo-application on Windows), prevented GtkApplication items from
being run for more than one time during the lifespan of the program,
and this also interfered with some GTK+ tests, causing them to fail.

Update accordingly to address the issue.
2013-08-21 20:28:26 +08:00
Sebastian Dröge
01156b122c GSocket – Implement multicast interface selection on Windows
https://bugzilla.gnome.org/show_bug.cgi?id=697185
2013-08-19 12:28:20 -04:00
Dan Winship
c069c51db5 gnetworkaddress: allow IPv6 scope ids in URIs
GNetworkAddress was allowing IPv6 scope ids in g_network_address_new()
/ g_network_address_parse(), but not in g_network_address_parse_uri().
Fix that.

Part of https://bugzilla.gnome.org/show_bug.cgi?id=669724
2013-08-19 12:15:36 -04:00
Dan Winship
e1f92431c1 gnetworkaddress: fix parsing of URIs with IPv6 literal and port
Addresses like "http://[::1]:8080/" were being parsed as though they
did not include a port. Fix that, and add some more parsing tests.
2013-08-19 12:15:36 -04:00
William Jon McCann
b0e6a38d95 Remove legacy icon name support
https://bugzilla.gnome.org/show_bug.cgi?id=684327
2013-08-17 21:53:33 -04:00
Matthias Clasen
0e9f9867fa Start using TAP
Convert {glib,gobject,gio}/tests to use the automake TAP driver
and test harness instead of gtester. To do so, we add a glib-tap.mk
that provides the same interface as glib.mk, except for the
reporting and coverage testing functionality. Eventually, we may
want to replace glib.mk with it. I've not yet converted the
toplevel tests/ directory, since it mixes gtestutils tests with
other binaries.

https://bugzilla.gnome.org/show_bug.cgi?id=692125
2013-08-17 17:25:58 -04:00
Matthias Clasen
de9cf58f65 GApplication: Stop using deprecated api 2013-08-17 17:25:56 -04:00
Dan Winship
547df5937c GSocket: fix g_socket_bind() allow_reuse semantics
With UDP sockets, g_socket_bind() with allow_reuse=TRUE on Linux
behaved in a way that the documentation didn't suggest, and that
didn't match other OSes. (Specifically, it allowed binding multiple
multicast sockets to the same address.)

Since this behavior is useful, and since allow_reuse didn't have any
other meaning with UDP sockets, update the docs to reflect the Linux
behavior, and make it do the same thing on non-Linux.

https://bugzilla.gnome.org/show_bug.cgi?id=689245
2013-08-17 13:26:42 -04:00
Dan Winship
2ea4af6f01 GSocket: fix broadcast documentation
The :broadcast property only affects sending broadcast packets, not
receiving them.
2013-08-17 13:26:42 -04:00
Dan Winship
f550c0dc9d update .gitignores 2013-08-17 10:35:13 -04:00
Daiki Ueno
a7f2765dba codegen: Treat input file as binary
Under C locale, open() in Python 3 sets the file encoding to ASCII.
As expat looks at encoding="..." in XML declaration, gdbus-codegen can
simply open the input file as binary and let expat decode the content.

https://bugzilla.gnome.org/show_bug.cgi?id=696633
2013-08-17 06:42:02 +02:00
Dan Winship
a93d373812 gio/tests/task: fix a race condition in test_run_in_thread()
When running a task in a thread, GTask may still be internally holding
a ref on the task in that thread even after the callback is called in
the original thread (depending on thread scheduling). Fix the test to
handle that by using a weak notify that signals a GCond, and wait for
that GCond from the main thread. (And add a corresponding check to
test_return_on_cancel().)

https://bugzilla.gnome.org/show_bug.cgi?id=705152
2013-08-15 12:43:57 -04:00
Matthias Clasen
844589b03e GSimpleActionGroup: Deprecated redundant API
See https://bugzilla.gnome.org/show_bug.cgi?id=705600
2013-08-13 16:48:51 -04:00
Cosimo Cecchi
a5fd296cc8 themedicon: correctly fallback to symbolic icons
When an icon is requested as symbolic, our generic fallback algorithm
uses fullcolor icons when the specified icon name is not found, treating
the "-symbolic" suffix as another component of the icon name.

Change the algorithm to check beforehand if the icon is symbolic, remove
the suffix if so, and re-add it at the end for all the generated icon
names.

https://bugzilla.gnome.org/show_bug.cgi?id=680926
2013-08-13 17:19:24 +02:00
Rico Tzschichholz
7c0d527fa6 GMenuModel: Fix typo in annotation 2013-08-01 20:41:50 +02:00
Daniel Svensson
8a1b553728 gdesktopappinfo: Add missing return value 2013-07-30 18:20:44 -04:00
Dan Winship
54a76e24b3 gsocket: fix a cut-and-pasted error message 2013-07-30 09:13:18 -04:00
Ryan Lortie
7a31a5010c GMenuModel: add annotations to virtual functions
Patch from Ted Gould.

https://bugzilla.gnome.org/show_bug.cgi?id=704931
2013-07-29 17:15:19 -04:00
Matthias Clasen
3bdd8a2c88 Use GLIB_PRIVATE_CALL macro
I accidentally pushed the fix for bug 704873 before
applying this cleanup.
2013-07-28 18:44:41 -04:00
Ryan Lortie
abbb225738 inotify: don't assume mainloop is running
GFileMonitor takes great care to sample the thread-default main context
at the time that it is created in order that events can be dispatched to
the correct thread when they come in.

The inotify GFileMonitor implementation uses a global file descriptor
shared between all watches.  It has to poll this file descriptor from
somewhere so it arbitrarily picks the default main context.

The problem with that is that the user might not be running it.

Let's use the GLib worker thread for this instead.  It's guaranteed to
be running if you need it, and this is exactly the sort of problem it
was meant to solve.

https://bugzilla.gnome.org/show_bug.cgi?id=704873
2013-07-28 17:19:38 -04:00
Matthias Clasen
5843582604 Fix build with statvfs
As pointed out in bug 704587, the maze of ifdefs was missing the
variable declaration for statfs_result in one case.

https://bugzilla.gnome.org/show_bug.cgi?id=704587
2013-07-28 17:04:56 -04:00
Dan Winship
8c748efce1 gnetworkaddress: tweak to make Solaris happy
https://bugzilla.gnome.org/show_bug.cgi?id=704704
2013-07-24 10:45:36 -04:00
Matthias Clasen
8753df9d70 gsettings tool: report failure to write
If a key is locked down, we should report an error if we
fail to write it.

https://bugzilla.gnome.org/show_bug.cgi?id=704424
2013-07-19 19:43:48 -04:00
Colin Walters
31aee73285 gdbusnameowning: Don't spew an error if we're releasing a name due to closing
The default GNOME 3.10 login process right now has gdm spawn a session
for the login screen, retaining the X server, but closing the session
bus.  Right now in this scenario many GNOME components such as
gnome-settings-daemon attempt to "clean up" on shutdown by releasing
their owned names.

But they're shutting down because the session bus went away, so
releasing the name is pointless, and presently spews an error into the
journal.

This patch avoids that error spew, which helps system administrators
find *real* problems.

https://bugzilla.gnome.org/show_bug.cgi?id=704567
2013-07-19 17:49:47 -04:00
Ryan Lortie
8ead9055b9 GApplication: reply to ActivateAction
Send a reply for org.freedesktop.Application.ActivateAction calls.  We
missed this before because nobody was waiting for it.
2013-07-14 19:48:01 -04:00
Matthias Clasen
06b968b6db Make a test desktop file a little less invalid
Add a missing Name entry, and add a terminal ; to the Actions
entry in org.gtk.test.dbusappinfo.desktop. desktop-file-validate
still contains about the DBusActivatable entry and about the
missing Exec entries. The former will go away when desktop-file-validate
gets updated for the latest spec revision.
2013-07-14 11:36:45 -04:00
Dan Winship
8d0e0c6fcc gcancellable: update GCancellableSource, fix a race condition
Update GCancellableSource to call g_source_set_ready_time() when its
cancellable is cancelled, rather than manually checking the state of
the cancellable from prepare() and check().

This means that we now need to use g_cancellable_connect() rather than
g_signal_connect() at construction time, to avoid the connect/cancel
race condition. Likewise, use g_cancellable_disconnect() to avoid the
disconnect/cancel race condition when freeing the source. (In fact,
that was necessary in the earlier code as well, and might have
occasionally caused spurious criticals or worse.)

https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Dan Winship
8f80fbb2a7 Remove some unnecessary source prepare/check functions
GPollableSource and GSocket's "broken" source never trigger on their
own, so with the changes to GSources in the last cycle, their check
and prepare functions are unnecessary (and undesired).

https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Dan Winship
6d328a0d5d gio: port unix streams to GUnixFDSource
The unix input/output streams were using a gio-only source type that
was mostly identical to GUnixFDSource. Get rid of that source type
and just use GUnixFDSource instead.

https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Dan Winship
1da47d5ede gsourceclosure: use g_cclosure_marshal_generic
For the glib-defined source types, and any source type that defines a
closure callback but not a closure marshal, use
g_cclosure_marshal_generic. And then remove all the other remaining
source closure marshals.

https://bugzilla.gnome.org/show_bug.cgi?id=701511
2013-07-13 16:38:55 -04:00
Ryan Lortie
cdff4a331e Fix g_return_if_fail vs. return_val_if_fail 2013-07-13 15:48:39 -04:00
Ryan Lortie
c04a063b78 GAction: add function for printing detailed names
A counterpart for parsing of detailed actions into (name, target) pairs,
this new function prints them back.

We also add a new function to check for validity of action names.  Only
valid action names are allowed when printing.  Parsing accepts _some_
invalid names for backwards compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=704157
2013-07-13 13:41:03 -04:00
Dan Winship
c08ef6c165 gnetworkmonitornetlink: handle default route via device
If the default route is via a device rather than a particular IP
address, then neither RTA_DST nor RTA_GATEWAY will be present in the
RTM_NEWROUTE message, and so GNetworkMonitorNetlink would ignore it,
and then think there was no default route. (This could happen with
certain kinds of VPNs, if they were set to route all traffic through
the VPN.)

Fix this by recognizing routes that specify RTA_OIF ("output
interface") instead of RTA_GATEWAY.

https://bugzilla.gnome.org/show_bug.cgi?id=701609
2013-07-12 11:59:50 -04:00
Ryan Lortie
973464781c Fix a typo in a filename in Makefile.am 2013-07-11 15:57:59 -04:00
Ryan Lortie
3b1b04433c Add a testcase for DBusActivatable=true
Add a fairly realistic testcase that ensures that GDesktopAppInfo with
DBusActivatable=true can successfully talk to GApplication for a variety
of purposes.

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-07-11 15:49:28 -04:00
Ryan Lortie
985e95e831 Add missing file
This got removed during the OnlyShowIn shuffle.
2013-07-11 13:49:20 -04:00
Ryan Lortie
9ec8ab62b2 GDesktopAppInfo: remove note about OnlyShowIn
A previous version of the patch had OnlyShowIn support for desktop file
actions.  This was removed from the spec and the patch rewritten, but
this bit of documentation slipped through.  Remove it.
2013-07-11 13:04:23 -04:00
Ryan Lortie
6dc5c118e4 Implement the Desktop Action specification
For some time, the desktop file specification has supported "additional
application actions".  This is intended to allow for additional methods
of starting an app, such as a mail client having a "Compose New Message"
action that brings up the compose window instead of the folder list.

This patch adds support for this with a relatively minimal API.

In the case that the application is a GApplication and DBusActivatable,
desktop actions are translated into GActions that have been added to the
application with g_action_map_add_action().  This more or less closes
the loop on being able to activate an application with an action
invocation (instead of 'activate').

https://bugzilla.gnome.org/show_bug.cgi?id=664444
2013-07-11 12:48:08 -04:00
Ryan Lortie
f77e121650 add GPropertyAction
Add a new type of GAction that represents the value of a property on an
object.  As an example, this might be used on the "visible-child-name"
property of a GtkStack.

https://bugzilla.gnome.org/show_bug.cgi?id=703270
2013-07-11 12:35:45 -04:00
Matthias Clasen
e38ee2f468 Document g_simple_proxy_resolver_set_ignore_hosts 2013-07-09 13:28:23 -04:00
Martin Ejdestig
4cd7bcaf00 Add missing G_BEGIN/END_DECLS to gsettingsschema.h.
Without this fix, using any of the enclosed functions when building with a
C++ compiler will result in undefined references.

https://bugzilla.gnome.org/show_bug.cgi?id=703478
2013-07-03 09:03:20 -04:00
Ryan Lortie
cb4469600c GDBusConnection: be more careful with async GetAll
It's possible to get a org.freedesktop.Properties.GetAll call even if we
have no readable properties in the introspection, in which case we
should return the empty list in the usual way.

We should certainly _not_ be dispatching to the method call handler of
an interface which has no properties (since it will not be expecting
this).

Add a check to make sure that there is at least one readable property
before assuming that a NULL get_property handler implies that we want to
handle properties asynchronously.

Add a testcase that was failing before the change and works after it.

https://bugzilla.gnome.org/show_bug.cgi?id=703437
2013-07-01 23:36:30 -04:00
Sébastien Wilmet
b05bf77223 Doc: small fixes
This commit adds the GTestSubprocessFlags enum to the docs, and fixes
several minor typos in various places.

https://bugzilla.gnome.org/show_bug.cgi?id=703254
2013-06-30 10:32:18 +02:00
Matthias Clasen
a3182e3b9a Improve various section headings in the docs
We don't use # or other forms of links in the section headings.
We also capitalize them and don't put a final period.

This commit corrects several headings to follow these rules.
2013-06-29 22:51:31 -04:00
Emmanuele Bassi
54cc43630d Rename the generated private data getter function
As it turns out, we have examples of internal functions called
type_name_get_private() in the wild (especially among older libraries),
so we need to use a name for the per-instance private data getter
function that hopefully won't conflict with anything.
2013-06-24 15:43:04 +01:00
Emmanuele Bassi
6000bc9ea8 gio: Missing G_ADD_PRIVATE in GFileInputStream 2013-06-24 15:43:00 +01:00
Emmanuele Bassi
32747def4b gio: Use the new private instance data declaration
Use the newly added macros, and remove the explicit calls to
g_type_class_add_private().

https://bugzilla.gnome.org/show_bug.cgi?id=700035
2013-06-24 14:18:01 +01:00
Dieter Verfaillie
fdc9379132 docs: fix GTK-Doc build
cd html && gtkdoc-mkhtml $mkhtml_options  gio ../gio-docs.xml
../xml/gdbusconnection.xml:2063: parser error : Opening and ending tag mismatch: literal line 2062 and para
</para>
       ^
2013-06-23 14:15:05 +02:00
Ryan Lortie
edf16aace4 GDBusMethodInvocation: add missing 'goto out'
We do a bunch of new validity checks for return values in response to
calls on the D-Bus property API but we miss the 'goto out' in one case.
Add it.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:41:12 -04:00
Ryan Lortie
317e8c132d GDBusMethodInvocation: add property return checks
Add some type checking for the values returned from async property
handling calls, similar in spirit to the type checking we do for normal
method calls.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:32 -04:00
Ryan Lortie
f754c4e85b GDBusConnection: allow async property handling
The existing advice in the documentation to "simply" register the
"org.freedesktop.DBus.Properties" interface if you want to handle
properties asynchronously is pretty unreasonable.  If you want to handle
this interface you have to deal with all properties for all interfaces
on the path, and you have to do all of the checking for yourself.  You
also have to provide your own introspection data.

Introduce a new convention for dealing with properties asynchronously.

If the user provides NULL for their get_property() or set_property()
functions in the vtable and has properties registered then the
properties are sent to the method_call() handler.  We get lucky here
that this function takes an "interface_name" parameter that we can set
to "org.freedesktop.DBus.Properties".

We also do the user the favour of setting the GDBusPropertyInfo on the
GDBusMethodInvocation for their convenience (for much the same reasons
as they might want the already-available GDBusMethodInfo).

Add a testcase as well as a bunch of documentation about this new
feature.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:31 -04:00
Ryan Lortie
c691f7b6ca GDBusMethodInvocation: add 'property_info'
Add a field on GDBusMethodInvocation for GDBusPropertyInfo.

For now, it is always %NULL.  It will be set in future patches.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:31 -04:00
Ryan Lortie
14dc028003 GDBusConnection: some straight-up refactoring
Separate the code for validating a method call from the code for
actually scheduling it for dispatch.

This will allow property Get/Set/GetAll calls to be dispatched to the
method_call handler without duplicating a lot of code.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:30 -04:00
Ryan Lortie
02f5cdd983 GDBusConnection: move 'Set' typecheck to worker
We presently do a lot of checks on property sets (signature check,
correct interface, property exists, etc.) from the worker thread before
dispatching the call to the user's thread.  The typecheck, however, is
saved until just before calling the user's vfunc, in their thread.

My best guess is that this was done to save having to unpack the value
from the tuple twice (since we don't unpack it until we're just about
the call the user).

This patch moves the check to the same place as all of the other checks.

The purpose of this change is to allow for sharing this check with the
(soon-to-be-introduced) case of handing property sets from
method_call().

This change has a minor side effect: error messages generated by sending
invalid values to property sets are no longer guaranteed to be correctly
ordered with respect to the void returns from successful property sets.
They will instead be correctly ordered with respect to the other error
messages.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:37:54 -04:00
Ryan Lortie
0d29b17af7 GDBusConnection: remove an unused g_variant_get()
https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:36:51 -04:00
Ryan Lortie
12958ed5cc gio/tests: sort tests in the Makefile.am
...to make it clear where people should add theirs, reducing the chance
of conflicts caused by everyone always adding at the end.
2013-06-08 17:01:56 -04:00
Ryan Lortie
afc8b1020a GDesktopAppInfo: support DBusActivatable
Support the sender-side of the freedesktop application specification for
cases that we find 'DBusActivatable=true' in the desktop file.

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-06-07 18:36:55 -04:00
Matthias Clasen
0aaac55d14 Update link to documentation 2013-06-06 00:06:46 -04:00
Dan Winship
6965b721b1 tests: fix and re-add the broken test 2013-06-05 23:49:56 -03:00
Matthias Clasen
1dac271ace Remove a failing testcase
One of the recently added examples seems wrong. Drop it.
2013-06-05 21:50:52 -04:00
Colin Walters
76a10a572c GFileEnumerator: Add some documentation about ordering
Kind of a gratuitious gaping hole in the docs...

https://bugzilla.gnome.org/show_bug.cgi?id=701680
2013-06-05 18:52:14 -04:00
Ryan Lortie
74a034028a tests: add a few more invalid IPv6 address tests
https://bugzilla.gnome.org/show_bug.cgi?id=701401
2013-06-05 19:48:29 -03:00
Dan Winship
59ed934b05 ginetaddress: fix addr/string conversions on windows
When parsing an address, we need to re-set "len" between IPv4 and
IPv6, since WSAStringToAddress() might set it to sizeof(struct sin_addr)
when trying to parse the string as IPv4, even if it fails. Also, we
need to make sure to not pass strings to WSAStringToAddress() that it
will accept but that we don't want it to.

When stringifying an address, we need to clear the sockaddr before
filling it in, so we don't accidentally end up with an unwanted
scope_id or the like.

https://bugzilla.gnome.org/show_bug.cgi?id=701401
2013-06-05 19:48:19 -03:00
Colin Walters
9f1a0b57cd Ensure g_file_copy() does not temporarily expose private files
Previously, g_file_copy() would (on Unix) create files with the
default mode of 644.  For applications which might at user request
copy arbitrary private files such as ~/.ssh or /etc/shadow, a
world-readable copy would be temporarily exposed.

This patch is suboptimal in that it *only* fixes g_file_copy()
for the case where both source and destination are instances of
GLocalFile on Unix.

The reason for this is that the public GFile APIs for creating files
allow very limited control over the access permissions for the created
file; one can either say a file is "private" or not.  Fixing
this by adding e.g. g_file_create_with_attributes() would make sense,
except this would entail 8 new API calls for all the variants of
_create(), _create_async(), _replace(), _replace_async(),
_create_readwrite(), _create_readwrite_async(), _replace_readwrite(),
_replace_readwrite_async().  That can be done as a separate patch
later.

https://bugzilla.gnome.org/show_bug.cgi?id=699959
2013-06-05 19:00:20 +01:00
Colin Walters
02aaef5a4d g_file_copy(): Clean up logic for info query
Previously, we called g_file_query_info() *again* on the source at the
very end of the copy.  This has the lame semantics that if the source
happened to be deleted, we would fail to apply attributes to the
destination.  This could even be a security flaw.

This commit changes things so that we query info from the source
*stream* after opening - i.e. on Unix we use the proper fstat() and
friends.  That way we operate more atomically.

https://bugzilla.gnome.org/show_bug.cgi?id=699959
2013-06-05 18:56:53 +01:00
Ryan Lortie
b4df86fa19 GApplication: implement fd.o application spec
The freedesktop application specification is largely overlapping the
GLib application D-Bus interface but implementing it will allow for
applications to be launched directly from desktop files, which we want.

We keep the old Gtk interface for compatibility reasons and because it
has some functionality not in the freedesktop spec (Busy state,
CommandLine, etc.).

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-06-05 12:50:50 -04:00
Ryan Lortie
7baea0aee5 GApplication: set prgname to appid for services
Since services are based on D-Bus activation and desktop files are
supposed to be named like the busname for DBusActivatable applications
and since gnome-shell wants wmclass equal to the desktop file name, we
therefore want wmclass equal to the application ID in this case.

wmclass is determined from the prgname, which is otherwise pretty
pointless to set to some random thing in $(libexec) for a D-Bus service,
so set that to the appid.

This means that for D-Bus services, the following things are now all the
same:

 - application ID
 - prgname
 - wmclass property set on all windows
 - desktop file name
 - well-known bus name

There are not many applications running as D-Bus services at present so
this shouldn't impact anybody except for gnome-clocks (where this change
will be fixing a bug) and gnome-terminal.

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-06-05 12:50:50 -04:00
Dan Winship
16b26231ca gio/tests/inet-address: fix to work on OS X
OS X's getaddrinfo() only supports IPv6 scope IDs that are interface
names, not numbers. So use if_indextoname() to get the name of an
interface and construct an address using that.

https://bugzilla.gnome.org/show_bug.cgi?id=700123
2013-06-04 09:24:47 -03:00
Matthias Clasen
d0301080ee Improve GSettings test coverage 2013-06-02 20:02:06 -04:00
Matthias Clasen
b9406904a5 Add a directory monitoring test 2013-06-02 20:02:06 -04:00
Matthias Clasen
e546eb016a Remove some unused inotify code 2013-06-02 20:01:56 -04:00
Ryan Lortie
a62079e2e3 tests: Remove a leftover debug printf
https://bugzilla.gnome.org/show_bug.cgi?id=701456
2013-06-02 09:53:24 -04:00
Matthias Clasen
fc35c3487e Improve unix stream test coverage 2013-06-02 01:47:19 -04:00
Matthias Clasen
8f655149e9 Improve GAppInfo test coverage 2013-06-02 01:46:21 -04:00
Matthias Clasen
0326f146fd Improve GMemoryInputStream test coverage 2013-06-02 01:44:49 -04:00
Matthias Clasen
dcf5dea922 Improve GMenuModel test coverage 2013-06-02 01:44:15 -04:00
Matthias Clasen
c40e0b59da Improve GFileAttributeMatcher test coverage 2013-06-02 01:43:13 -04:00
Matthias Clasen
0753ae1235 Improve GIcon test coverage 2013-06-02 01:42:28 -04:00
Matthias Clasen
49d39633d1 Improve test coverage for GZipCompressor 2013-06-02 01:41:50 -04:00
Matthias Clasen
2f3f270fcc Improve test coverage for GBufferedOutputStream 2013-06-02 01:41:09 -04:00
Matthias Clasen
6a487eae56 Trivial formatting fix 2013-06-02 01:40:39 -04:00
Matthias Clasen
fed8ae38c3 Improve test coverage a bit 2013-06-01 18:51:25 -04:00
Ryan Lortie
79972d22ac Fix failure to build exit-on-close gdbus test
In the case that HAVE_DBUS_DAEMON was undefined (as in ostree where glib
is built before D-Bus) this test was failing.  Move it inside the
HAVE_DBUS_DAEMON block.
2013-06-01 11:38:10 -04:00
Ryan Lortie
e042db0f83 GSettings tests: reverse installed test complexity
Remove the complications that were introduced in an attempt to make the
gsettings and gschema-compile tests function as installed tests.  These
tests are designed (in large part for gsettings and entirely for
gschema-compile) to test the in-tree tools and should not be testing the
system versions.

In the future we may want to move the use of the in-tree tools from the
gsettings testcase into the Makefile and install the resulting files,
allowing this testcase to run against those files, installed.
2013-05-31 23:16:00 -04:00
Ryan Lortie
f9eb9eed10 Rework the build system for a new tests approach
Perform a substantial cleanup of the build system with respect to
building and installing testcases.

First, Makefile.decl has been renamed glib.mk and substantially
expanded.  We intend to add more stuff here in the future, like canned
rules for mkenums, marshallers, resources, etc.

By default, tests are no longer compiled as part of 'make'.  They will
be built when 'make check' is run.  The old behaviour can be obtained
with --enable-always-build-tests.

--disable-modular-tests is gone (because tests are no longer built by
default).  There is no longer any way to cause 'make check' to be a
no-op, but that's not very useful anyway.

A new glibtests.m4 file is introduced.  Along with glib.mk, this
provides for consistent handling of --enable-installed-tests and
--enable-always-build-tests (mentioned above).

Port our various test-installing Makefiles to the new framework.

This patch substantially improves the situation in the toplevel tests/
directory.  Things are now somewhat under control there.  There were
some tests being built that weren't even being run and we run those now.
The long-running GObject performance tests in this directory have been
removed from 'make check' because they take too long.

As an experiment, 'make check' now runs the testcases on win32 builds,
by default.  We can't run them under gtester (since it uses a pipe to
communicate with the subprocess) so just toss them in TESTS.  Most of
them are passing on win32.

Things are not quite done here, but this patch is already a substantial
improvement.  More to come.
2013-05-31 23:12:15 -04:00
Ryan Lortie
e66abbe2ef Some final g_test_build_filename() porting
This should be the last users that need to be ported.

For some of the oldschool non-gtester-ified tests, we call g_test_init()
from main() because it is necessary in order to use
g_test_build_filename().
2013-05-31 23:03:19 -04:00
Matthias Clasen
a114e98d09 Split off the gdbus-overflow test
It is unrealiable under load, and frequently fails in the
ostree tests. See https://bugzilla.gnome.org/show_bug.cgi?id=701105
2013-05-31 21:24:21 -04:00
Ryan Lortie
ccc039c705 Remove org.gtk.test.gschema
This is the old non-xml schema file format that we were playing around
with at one time.  Nothing is using this file anymore.
2013-05-29 23:31:19 -04:00
Ryan Lortie
c235087ba4 icon deserialisation: fix uninitialised variable
Deserialising an emblemed icon would make uninitialised use of a
variable in the error case.  Fix that.
2013-05-29 21:49:53 -04:00
Ryan Lortie
8df1bb3486 Rename G_TEST_DISTED to G_TEST_DIST
Since this feature is so utterly automake-centric, we may as well be
using the same terminology as automake itself (ie: although it's
BUILT_SOURCES, it's DIST_EXTRA, not DISTED).

Also add some comments to the enum explaining that these terms are
really corresponding directly to the automake terms.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:32 -04:00
Ryan Lortie
da478acd3c Remove G_TEST_DATA= from installed .test files
This is no longer needed with the new test data file finding stuff.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:32 -04:00
Ryan Lortie
ddd7e941f4 Test data file API: port two more testcases
These ones were slightly non-trivial so they didn't get included in the
previous patches.  Port them now.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:32 -04:00
Ryan Lortie
17ded322c5 tests: move tests to new _get_filename() API
This API was introduced to save a few lines of code here and there, so
let's start by removing a bunch from our own tests.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:32 -04:00
Ryan Lortie
58c6ca32aa tests: use new g_test_build_filename() API
Port most of the tests to the new g_test_build_filename() API.

https://bugzilla.gnome.org/show_bug.cgi?id=549783
2013-05-29 09:03:31 -04:00
Emanuele Aina
3382ac99be GIcon: NULLify the `type' out param in the sync methods too
Both g_[file|bytes]_icon_load() leave the `type' out parameter
untouched, while the async methods g_[file|bytes]_icon_load_finish()
always set it to NULL.

For consistency's sake NULLify it in the sync methods too.

https://bugzilla.gnome.org/show_bug.cgi?id=700725
2013-05-28 22:59:24 +02:00
Matthias Clasen
98a921045c Fix make check with builddir != srcdir
This broke when the tests were converted to be installable.
My apologies.
2013-05-27 21:21:55 -04:00
Colin Walters
4ec32e6fa8 gio/tests: Make gdbus-proxy-well-known-name handle srcdir != builddir 2013-05-27 19:30:31 -04:00
Ryan Lortie
7336a1e745 Fix yet more test regressions... 2013-05-27 18:34:53 -04:00
Ryan Lortie
42139d4637 One more broken test.... 2013-05-27 18:34:53 -04:00
Ryan Lortie
8f87d428a6 More srcdir != destdir tests fallout 2013-05-27 18:27:26 -04:00
Matthias Clasen
b382c6f633 Avoid a segfault in gdbus tool
When the interface name is invalid, we don't get an error
back from g_dbus_connection_call_sync.
2013-05-25 23:15:36 -04:00
Colin Walters
0b167b0ae9 build: Fix usage of %.test again
We actually need the first dependency because it includes the
final executable name.  Rather, fix the original bug by using
the variable $(EXEEXT).
2013-05-24 22:16:44 +01:00
Colin Walters
5088c705ac tests: Drop unnecessary % from .test pattern match rule
On Windows, the executables will have .exe, so this won't
match.  Furthermore, they aren't actually dependent on the
executable to build.
2013-05-24 16:30:21 -04:00
Elisabeth Henry
7427e22958 gunixconnection: added ngettext to support plural forms
While those strings ("Expecting 1 control message, got %d" and
"Expecting one fd, but got %d\n") have same singular/plural form
in english, it is not necessarily the case in other languages.

https://bugzilla.gnome.org/show_bug.cgi?id=695233
2013-05-23 21:48:28 -04:00
Colin Walters
7fc2ab9493 GLocalFileOutputStream: Further deduplicate error code path
Just code cleanup.

https://bugzilla.gnome.org/699959
2013-05-23 23:11:58 +01:00
Colin Walters
5e65cd4e51 GLocalFileOutputStream: Deduplicate stream creation code
Lots of copy/paste of the error handling path, let's deduplicate
so I can sanely patch this code later.

https://bugzilla.gnome.org/699959
2013-05-23 23:10:44 +01:00
Colin Walters
49030c8797 gdbus-peer: Drop some usage of g_thread_yield()
It's a recipe for race conditions and error; on some hardware
architectures one thread isn't guaranteed to see the results
of writes from another thread without a cache flush.

https://bugzilla.gnome.org/show_bug.cgi?id=700855
2013-05-23 10:11:21 -04:00
Josep Puigdemont
c9cc0beb3a Timeout the test if dbus sevice has not appeared in due time.
The test /gdbus/connection/large_message waits for a dbus name to appear.
The dbus name is created by a another process executed in the background.
If for some reason this fails, the test will likely wait forever.
This will avoid this situation by making the test fail if the dbus service
has not appeared after 10 seconds.

https://bugzilla.gnome.org/show_bug.cgi?id=698981
2013-05-21 11:18:08 -04:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.

However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.

Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.

Fix this by just using 'dumb quotes' everywhere.

https://bugzilla.gnome.org/show_bug.cgi?id=700746
2013-05-21 11:23:22 -03:00
Colin Walters
bb1a5ca9a8 gio/tests: Fix gdbus-connection when run from "make check" 2013-05-21 09:21:21 -04:00
Colin Walters
c26e253b10 gio/tests: gsettings is a developer-only test
It tries to run glib-compile-schemas and glib-mkenums, which
we won't have in the runtime tree.

Anyways it's kind of a dumb test since the best test for
compilation tools is...compiling things, which we already
do frequently.
2013-05-21 00:12:31 +01:00
Colin Walters
c12538a9c0 gio/tests: Disable desktop-app-info test in installed mode for now
It wants a writable copy of the applications, and appears to
depend on a prior execution of "mimeapps".  This will take
a bit of work to untangle.
2013-05-21 00:02:39 +01:00
Colin Walters
3d7fcc23c1 gio/tests: Make gdbus-peer work in installed mode
There's no /etc/hosts in gnome-ostree...
2013-05-20 21:50:28 +01:00
Colin Walters
7ee44da5cf gio/tests: Fix gapplication test in installed mode 2013-05-20 21:43:52 +01:00
Colin Walters
1a398b2e56 gio/tests: Some more fixes for installed tests
file passes now, appinfo needs a bit more work, but is getting
there.
2013-05-20 21:33:00 +01:00
Colin Walters
bdf383dcd6 gio/tests: Deduplicate Makefile.am a bit
We can just add all the static test data to EXTRA_DIST.
2013-05-20 20:15:43 +01:00
Matthias Clasen
142d78214d Convert remaining gio tests to installed 2013-05-20 08:46:21 -04:00
Matthias Clasen
5e1f9173c3 Convert some gio tests to installed tests 2013-05-20 06:38:41 -04:00
Dan Winship
e9284ed297 gtestutils: deprecate g_test_trap_fork()
https://bugzilla.gnome.org/show_bug.cgi?id=679683
2013-05-13 12:10:53 -04:00
Dan Winship
e3d1869ee3 tests: port from g_test_trap_subprocess() to g_test_trap_fork()
https://bugzilla.gnome.org/show_bug.cgi?id=679683
2013-05-13 12:10:52 -04:00
Christian Persch
1d310cf5db app: Document when floating variants are consumed
Bug #700203.
2013-05-13 13:45:11 +02:00
Zeeshan Ali (Khattak)
c2d6aaa540 Fix minor typos in GSocketConnectable example code 2013-05-08 03:55:39 +03:00
Sebastian Dröge
25fa94eb82 Declare res_init() for builds against Android's Bionic
res_init() exists in the C library here and as such is detected
by configure, but it is not declared in any header.
2013-05-06 16:06:48 +02:00
Dan Winship
f4a1882341 GProxyAddressEnumerator: add default-port property
Although none of the in-tree GSocketConnectable types need it, other
types (like SoupAddress) may find it useful to be able to pass a URI
and a default-port to GProxyAddressEnumerator separately (the same way
you can with GNetworkAddress). So add a default-port property.

https://bugzilla.gnome.org/show_bug.cgi?id=698877
2013-05-05 16:50:43 -04:00
Matthias Clasen
9d69c274e0 Silently handle icon being NULL
While an emblemed icon without a base icon is not very
useful, no need to crash here.
This was crashing the object finalization test in gtk.
2013-05-02 21:02:37 -04:00
Simon McVittie
769e3edbe0 GSocks5Proxy: don't crash if parsing negotiation reply fails
The GError should be initialized to NULL, otherwise we'll
"pile up" errors, then try to free an uninitialized pointer.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=699493
2013-05-02 18:37:25 +01:00
Tim Lunn
daf7f56491 gio: fix small leak
https://bugzilla.gnome.org/show_bug.cgi?id=699361
2013-05-01 11:15:13 +10:00
Ryan Lortie
0646e00e25 GApplication: don't leak 'hint' on remote Open
We were using format string "s" to deconstruct the open hint into a
'const gchar *' which, of course, we never freed.  Fix that.
2013-04-29 13:39:55 -07:00
Cosimo Cecchi
706e636ab8 bytesicon: don't use g_object_unref() on GBytes
We need to use g_bytes_unref()

https://bugzilla.gnome.org/show_bug.cgi?id=699001
2013-04-26 17:12:39 -04:00
Cosimo Cecchi
463022cc09 bytesicon: fix a memory leak
https://bugzilla.gnome.org/show_bug.cgi?id=698999
2013-04-26 17:08:06 -04:00
Mike Ruprecht
c027e88a30 gio/tests: Find "true" in PATH opposed to hardcoding the location
Not all systems have /usr/bin/true. Some have it in /bin/true.
Instead of trying to guess a hardcoded path to find it, let
g_app_info_create_from_commandline() internally search PATH
to find the program.

https://bugzilla.gnome.org/show_bug.cgi?id=698655
2013-04-25 02:54:14 -05:00
Cosimo Cecchi
03dd6cf1b5 docs: fix docs for g_icon_[de]serialize() 2013-04-24 11:58:47 -04:00
Ryan Lortie
c91af2ab44 Test GUnixSocketAddress construction
This test fails without the previous fix and works properly with it.

https://bugzilla.gnome.org/show_bug.cgi?id=698686
2013-04-23 14:36:07 -04:00
Ryan Lortie
9c243beea2 GUnixSocketAddress: fix construct parameter issue
GUnixSocketAddress has some very strange logic for interpreting its
construct paramters.  This logic behaves differently in these two cases:

  g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
                "abstract", FALSE,
                "address-type", ...,
                NULL);

and

  g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
                "address-type", ...,
                NULL);

even though the default value for "abstract" is already FALSE.

Change the way the code works so that it is not sensitive to people
merely setting a property to its default value.

https://bugzilla.gnome.org/show_bug.cgi?id=698686
2013-04-23 14:36:07 -04:00
Ryan Lortie
c1c1b33f88 GMenu: add g_menu_item_set_icon() convenience
This function takes a GIcon, serialises it and sets the resulting
GVariant as the "icon" attribute on the menu item.  We will need to add
a patch to Gtk to actually consume this icon.

Also add G_MENU_ATTRIBUTE_ICON.

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-22 16:12:42 -04:00
Jasper St. Pierre
63a0cc3f8d tests: Fix appinfo test 2013-04-22 13:12:20 -04:00
Ryan Lortie
c16f914b40 GIcon: add g_icon_[de]serialize()
Add support for serialising a GIcon to a GVariant and deserialising the
result back to a GIcon.

This solves a number of problems suffered by the existing to_string()
API, primarily these:

 - not forcing the icon to be a utf8 string means that we can
   efficiently encode a PNG (ie: just give the array of bytes)

 - there is no need to ensure that proper types are loaded before using
   the deserialisation interface.  'Foreign' icon types will probably
   emit a serialised format the deserialises to a GBytesIcon.

We additionally clearly document what is required for being a consumer
or implementation of #GIcon.

Further patches will be required to GdkPixbuf and GVfsIcon to bring
their implementations in line with the new rules (essentially: introduce
implementations of the new serialize() API).

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:31:14 -04:00
Ryan Lortie
9cc222c0bf Introduce GBytesIcon
GBytesIcon is an icon that has a GBytes inside of it where the GBytes
contains some sort of encoded image in a widely-recognised file format.
Ideally this will be a PNG.

It implements GLoadableIcon, so GTK will already understand how to use
it, but we will add another patch there to make things more efficient.

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:25:15 -04:00
Ryan Lortie
519e989ea8 GIcon: pure re-factor of _from_string()
Split out the 'simple string format' cases of URIs, file paths and
themed icons to a separate function.

This function will be shared by g_icon_deserialize().

https://bugzilla.gnome.org/show_bug.cgi?id=688820
2013-04-21 16:25:13 -04:00
Jasper St. Pierre
c0af442909 gdesktopappinfo: Allow getting the desktop ID from the filename 2013-04-21 00:09:47 -04:00
Lars Uebernickel
390115f385 gactionmap: don't require GActionGroup
https://bugzilla.gnome.org/show_bug.cgi?id=698478
2013-04-20 22:10:36 -04:00
Sébastien Wilmet
a2a44a9617 Add async version of g_file_make_directory()
https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-19 21:38:13 +02:00
Sébastien Wilmet
bd57c3f171 GFile: fix the *_async_thread()
In the *_async_thread() functions, call the corresponding synchronous
function instead of calling the interface vfunc, which can be NULL.

In some cases the check for the vfunc == NULL was done, but to be
consistent it is better to always call the synchronous version (and the
code is simpler).

https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-19 21:38:13 +02:00
Ryan Lortie
1de0625103 GMenu: add g_menu_remove_all() API
Removes all of the items from a GMenu.  The keyboard indicator wants to
do this as part of refreshing the layout list, as an example.

https://bugzilla.gnome.org/show_bug.cgi?id=697601
2013-04-19 14:52:51 -04:00
Sebastian Dröge
bcbaf1bef0 Fix compilation on Android with the bionic C library
https://bugzilla.gnome.org/show_bug.cgi?id=689223
2013-04-16 13:24:26 +02:00
Sébastien Wilmet
733bf96202 Add async version of g_file_trash()
https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-10 22:32:33 +02:00
Sébastien Wilmet
c35b73a90f Add missing details in GFile documentation
https://bugzilla.gnome.org/show_bug.cgi?id=548353
2013-04-10 20:31:44 +02:00
Lionel Landwerlin
74ed1cf5b0 gunixmounts: remove warning on unused variable
https://bugzilla.gnome.org/show_bug.cgi?id=697367
2013-04-10 11:07:12 +01:00
Lars Uebernickel
00f6d78125 g_dbus_connection_signal_subscribe: add path and namespace matching
https://bugzilla.gnome.org/show_bug.cgi?id=695156
2013-04-08 15:59:39 +02:00
Lionel Landwerlin
d474309c3f gunixmounts: correctly flag hasmntopt usage
https://bugzilla.gnome.org/show_bug.cgi?id=697365
2013-04-07 07:11:30 +01:00
Cosimo Cecchi
db325cd6a3 application: introduce methods to mark the application as busy
This feature is intended for clients that want to signal a desktop shell
their busy state, for instance because a long-running operation is
pending.
The API works in a similar way to g_application_hold and
g_application_release: applications can call g_application_mark_busy()
to increase a counter that will keep the application marked as busy
until the counter reaches zero again.

The busy state is exported read-only on the org.gtk.Application interface
for clients to use.

https://bugzilla.gnome.org/show_bug.cgi?id=672018
2013-04-04 13:13:53 -04:00
David Gomes
bfb6ff0dbd gsettings: implemented --version command
This was discussed in
https://bugzilla.gnome.org/show_bug.cgi?id=697131
2013-04-03 21:35:57 -04:00
Giovanni Campagna
3456152f23 GThreadedResolver: set an error if no records could be found
It is possible that the upstream servers return something, but
we then filter all results because they are of the wrong type.
In that case the API and subsequent GTask calls expect a GError
to be set.

https://bugzilla.gnome.org/show_bug.cgi?id=696857
2013-04-02 23:04:15 +02:00
Guido Günther
31c00c1fbe codegen: move G_DEFINE_INTERFACE{,_WITH_CODE} before _default_init
to avoid warnings when built with -Wredundant-decls:

  sessionmanager-presence-generated.c:316:1: warning: redundant redeclaration of ‘session_manager_presence_default_init’ [-Wredundant-decls]
  sessionmanager-presence-generated.c:281:1: note: previous definition of ‘session_manager_presence_default_init’ was here
  sessionmanager-presence-generated.c:1273:1: warning: redundant redeclaration of ‘object_default_init’ [-Wredundant-decls]
  sessionmanager-presence-generated.c:1259:1: note: previous definition of ‘object_default_init’ was here

https://bugzilla.gnome.org/show_bug.cgi?id=696108
2013-04-02 21:49:59 +02:00
Guido Günther
576e2ce1db codegen: Avoid warnings when the generated client code is built with -Wunused-parameter
https://bugzilla.gnome.org/show_bug.cgi?id=696108
2013-04-02 21:49:54 +02:00