Commit Graph

1594 Commits

Author SHA1 Message Date
Dan Winship
547311bfd8 Always do async vs sync correctly in GSocketConnection streams
Previously if a GSocketConnection had a blocking GSocket, it would
sometimes block during asynchonous I/O, and if it had a non-blocking
socket, it would sometimes return G_IO_ERROR_WOULD_BLOCK from
synchronous I/O. This fixes the connection to not depend on the socket
state.

https://bugzilla.gnome.org/show_bug.cgi?id=616458
2010-08-15 15:34:29 -04:00
Dan Winship
17fea2f749 Belatedly add g_socket_client_get/set_timeout to docs and symbols 2010-08-15 13:11:49 -04:00
Dan Winship
b76b24f1b3 GSocketClient: plug two leaks
g_socket_client_connect_async() was always leaking its GCancellable,
and would also leak any GSocket that eventually failed to connect
after returning G_IO_ERROR_PENDING.
2010-08-14 16:15:39 -04:00
Dan Winship
16bafb4799 GSocketClient: add a timeout property
GSocket has a timeout flag now, but when using GSocketClient there was
no way to set the timeout until after connecting (or failing). Fix
that by adding a timeout property to GSocketClient.
2010-08-14 15:26:16 -04:00
Will Thompson
28a4fff7ec Add examples for GAsyncInitiable and GSimpleAsyncResult
Bug 602417
2010-08-13 23:34:44 -04:00
Will Thompson
7a32e34f7c Document that _complete() et al. ref the GSimpleAsyncResult 2010-08-13 23:20:06 -04:00
Will Thompson
ec31612ea0 _simple_async_result_is_valid: allow tag to be NULL
Because g_simple_async_report_[g]error_in_idle() don't take a source tag
parameter, code that uses them can't currently use
g_simple_async_result_is_valid() (at least, not for the error case).

Bug 602417
2010-08-13 23:15:27 -04:00
Matthias Clasen
e02571e93b Add bug references to some tests 2010-08-13 21:23:23 -04:00
Matthias Clasen
ea8a963936 Document vendor override files
Features without documentation, tsk tsk.
2010-08-13 21:23:22 -04:00
Matthias Clasen
4160c5c74a Add tests for async file replace and load 2010-08-13 19:40:48 -04:00
Matthias Clasen
c003468296 Correct a comment 2010-08-13 17:23:44 -04:00
Matthias Clasen
93bd5298c7 Add an async file create/write/read/delete test 2010-08-13 17:23:44 -04:00
Matthias Clasen
7ed4762190 Fix a typo, and some doc reformatting 2010-08-13 17:23:44 -04:00
Matthias Clasen
effdb785fd Add some long descriptions for filter streams 2010-08-13 17:23:44 -04:00
Matthias Clasen
13e55b84eb Run volumemonitor test with local vfs
This is an attempt to stop the test from hanging on some build bots
in build.gnome.org.
2010-08-13 17:23:44 -04:00
David Zeuthen
d344ff9d67 Bug 626841 – Add test-case for non-socket GIOStream
Also fix a couple of bugs so it actually works.

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

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-13 14:01:36 -04:00
Michael Meeks
9be94e8899 Add test for EAGAIN overflow in gdbusconnection based on David's test. 2010-08-13 17:56:19 +01:00
Matthias Clasen
5d9d3f0318 Add some async file tests 2010-08-13 12:04:21 -04:00
Tor Lillqvist
398f9841ed Fix gio/win32 build after -I flag changes 2010-08-10 16:01:39 +03:00
Matthias Clasen
14e0ad7c53 Don't compile some unused functions in gio/xdgmime/ 2010-08-08 21:32:04 -04:00
Matthias Clasen
584787f580 Improve the async result test coverage 2010-08-08 21:32:03 -04:00
Matthias Clasen
7c129c9011 Improve dbus address test coverage 2010-08-08 21:32:03 -04:00
Matthias Clasen
51ad83f711 Make g_dbus_error_unregister_error work 2010-08-07 18:56:12 -04:00
Matthias Clasen
8e236f7ec1 Add some more test about gdbus_error apis 2010-08-07 18:55:21 -04:00
Matthias Clasen
7de6658f74 Make g_simple_async_result_is_valid work without source
The problem was pointed out by Xavier Claessens in bug 626208.
2010-08-07 17:10:17 -04:00
Matthias Clasen
402ad1958c Make the closure variants of name owning and watching actually work
The GClosure API is a bit funky (and badly documented), and requires
you to set a marshaller on the closure, and the marshaller has an
implicit 'this' argument, and the caller is reponsible for unsetting
the values after invoking the closure.

I've added some calls of the _with_closures variants to the
gdbus-names test now.
2010-08-07 17:10:17 -04:00
Ryan Lortie
b91f9274d9 Fix volumemonitor test case
Don't blindly g_object_unref() that which may be NULL.
2010-08-06 13:12:20 -04:00
Ryan Lortie
889a7f81dd gio.symbols: add g_dbus_message_[gs]et_byte_order 2010-08-06 13:11:38 -04:00
Ryan Lortie
b3b7ea8e22 Replace -I with $(glib_INCLUDES) and friends
Stop using ad hoc -I in all of our Makefile.am.  Use the new variables
instead.
2010-08-06 13:10:34 -04:00
Ryan Lortie
ba0208b3a8 Clean up improper #includes
We have a lot of broken #including going on around the tree.  This has
gone unnoticed due to our sloppy use of -I.
2010-08-06 13:05:18 -04:00
paul
9f6faaffb6 Add $(top_builddir)/glib to includes
This is required to find glibconfig.h during srcdir != builddir builds
2010-08-05 09:08:34 -04:00
David Zeuthen
d52e1c33f7 GDBus: Add `return' debug option
This prints all GDBusMethodInvocation API usage and is normally used
with the `incoming' option. Example:

 # G_DBUS_DEBUG=incoming,return ./polkitd --replace
 Entering main event loop
 Connected to the system bus
 Registering null backend at priority -10
 [...]
 Acquired the name org.freedesktop.PolicyKit1
 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.26
       serial 299
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD ERROR org.freedesktop.PolicyKit1.Error.Failed
       message `Cannot determine session the caller is in'
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.26
       reply-serial 299

 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.2402
       serial 25
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD RETURN
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.2402
       reply-serial 25

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 16:59:26 -04:00
David Zeuthen
89a1b571ad GDBusMessage: Validate header fields when serializing/deserializing
The D-Bus spec mentions exactly what header fields are required for
various message types. Add tests for this as well.

Also disallow empty interfaces for signals since the D-Bus spec says
this is Verboten already.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 14:38:51 -04:00
David Zeuthen
6f070be65b GDBusMessage: Add a way to get/set byte order of a message
Also use this in the test cases to check that serialization to and
from both big and little endian works.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 13:34:14 -04:00
David Zeuthen
6e723e8b3e GDBusMessage: Assert various things when serializing to a blob
We use g_assert() instead of setting the GError because it is a
programming error if the GVariant contains invalid data - see commit
5e6f762d61 for where the last hole in
GVariant was closed.

So if we can trust GVariant to only contain valid data (ignoring the
case where unsafe API such as g_variant_new_from_data() is used), why
g_assert() at all with costly g_utf8_validate() checks? Because a) it
is relatively inexpensive; and b) it helps find bugs such as the one
fixed in commit 5e6f762d61.

If performance is a concern we can play games like introducing
environment variables or other machinery to avoid such "costly"
checks. I doubt it will ever be an issue.

Also replace two "Hmm" TODO item with a static assert - the code that
serializes a gdouble into the D-Bus wire format by treating it as a
guint64 is indeed correct - endianess needs to be taken into account
(see the D-Bus reference implementation for similar code). But we want
to make sure that we're indeed using an architecture/compiler where a
gdouble takes up 8 bytes - hence the assertion.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 12:24:22 -04:00
David Zeuthen
5bd34a820e GDBusMessage: Validate UTF-8 strings when serializing from blob
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 11:26:48 -04:00
Dan Winship
e62bc8e8f6 remove a junk line 2010-08-04 07:36:34 -04:00
David Zeuthen
f5cd8ddeaa GDBusConnection: Debug messages when receiving signals and method invocations
Spell out "RECEIVED SIGNAL" instead of "SIGNAL" to emphasize this is
about receiving a signal, not emitting one (which is "SIGNAL
EMISSION"). Also make the "arrows" point in the "right" direction
("<<<<" vs ">>>>") - like this:

 ========================================================================
 GDBus-debug:Signal:
  <<<< RECEIVED SIGNAL org.freedesktop.DBus.NameOwnerChanged
       on object /org/freedesktop/DBus
       sent by name org.freedesktop.DBus

and

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.EnumerateTemporaryAuthorizations()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.2176

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-03 15:36:16 -04:00
David Zeuthen
69341e2ba9 glib-compile-schemas: Pass a C string, not a GString wrapper
Commit 5e6f762d61 (introducing UTF-8
validity checks for GVariant instances containing strsings) actually
uncovered a bug in glib-compile-schemas - a GString was passed when a
C string was expected.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-03 14:32:29 -04:00
David Zeuthen
86d947f01f Fix gdbus-exit-on-close test case
Forgot to update the test case after last commit.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-03 12:47:07 -04:00
David Zeuthen
6a492a4519 GDBus: If exiting b/c remote peer disconnected and error is set, print it
This should make things easier to debug:

  g_dbus_connection_real_closed: Remote peer vanished with error:
  Underlying GIOStream returned 0 bytes on an async read
  (g-io-error-quark, 0). Exiting.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-03 12:24:48 -04:00
David Zeuthen
3940cc9a11 GDBusProxy: Don't leak a GSimpleAsyncResult when doing async calls
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-03 11:14:21 -04:00
Matthias Clasen
b2715bbc5e Fix a possible deadlock
the FdSource was calling g_cancellable_disconnect while holding the
main context lock, which is bad news if the ::cancelled handler is
trying to get that lock to wake up the mainloop...

Bug 586432
2010-08-03 10:41:21 -04:00
Emmanuele Bassi
b3de028a43 Update the Git ignore files 2010-08-03 14:21:02 +01:00
Ryan Lortie
ca3b7b75bf GSettings: add G_SETTINGS_BIND_INVERT_BOOLEAN flag
When binding a boolean setting to a boolean property, invert the values.
This avoids the requirement for writing a pair of mapping functions for
this extremely common case.

Add a test.

https://bugzilla.gnome.org/show_bug.cgi?id=625833
2010-08-03 02:09:10 -04:00
Fridrich Štrba
dd2bbc9533 On windows, export also symbols defined in gio/gwin32appinfo.c 2010-08-02 10:16:29 +02:00
Carlos Garcia Campos
892012b951 GDBusConnection: fix message flags in g_dbus_connection_call_sync()
GDBusCallFlags were used instead of GDBusSendMessageFlags for
g_dbus_connection_send_message_with_reply_sync(). Fixes bug #625753.
2010-08-01 17:27:58 +02:00
Milan Crha
d01a437490 Silence valgrind
Initialize all fields of struct msghdr. Bug 625472.
2010-07-31 23:51:45 -04:00
Matthias Clasen
8246bf4bde Improve gdbus test coverage 2010-07-31 00:13:02 -04:00
Matthias Clasen
116b945c94 Fix a typo
Its credentials, not crendentials
2010-07-30 23:44:30 -04:00
Matthias Clasen
eb3e926b09 Fix an off-by-one error 2010-07-30 19:53:29 -04:00
Matthias Clasen
5033be80d1 Add a test for g_dbus_proxy_get_cached_property_names 2010-07-30 19:51:22 -04:00
Matthias Clasen
aa196c60df Improve coverage of buffered output stream tests 2010-07-30 19:51:21 -04:00
Matthias Clasen
ffa938fc65 Improve coverage of credentials tests 2010-07-30 19:51:21 -04:00
Matthias Clasen
670528c187 Improve coverage of converter stream tests 2010-07-30 19:51:21 -04:00
Matthias Clasen
9794a648a9 Improve coverage of memory stream tests 2010-07-30 19:51:21 -04:00
Matthias Clasen
620582e59c Remove redundant include 2010-07-30 19:51:20 -04:00
Matthias Clasen
17d4898d75 Improve coverage of icon tests 2010-07-30 19:51:20 -04:00
Matthias Clasen
7710c50fb2 Improve coverage of application tests 2010-07-30 19:51:20 -04:00
Matthias Clasen
758c3216cd Improve coverage of stream tests 2010-07-30 19:51:20 -04:00
Matthias Clasen
c6b0507167 Reenable unix-streams test 2010-07-30 19:51:20 -04:00
Matthias Clasen
04c7abba11 Work around deadlock in unix-streams test 2010-07-30 19:51:20 -04:00
Matthias Clasen
b463b2ea25 Add tests about file associations 2010-07-30 19:51:20 -04:00
Matthias Clasen
13ac9f94fd Add some more GFile tests 2010-07-30 19:51:19 -04:00
Matthias Clasen
8263d691cb Improve compressor test coverage a bit 2010-07-30 19:51:19 -04:00
Matthias Clasen
b77a19f238 Test g_settings_list_schemas 2010-07-30 19:51:19 -04:00
Matthias Clasen
caa9453b72 Fix a warning 2010-07-30 19:51:18 -04:00
Matthias Clasen
d0750c9d6e Don't leak in converter test 2010-07-30 19:51:18 -04:00
Matthias Clasen
63bdeb0dab Fix an icon test 2010-07-30 19:51:17 -04:00
Matthias Clasen
a8f83ea834 Add tests for GNetworkAddress 2010-07-30 19:51:17 -04:00
Matthias Clasen
e103b93694 Drop an unneeded if 2010-07-30 19:51:17 -04:00
Matthias Clasen
9fc3c980cc Add some volume monitor tests
Although not much of this is easily testable.
2010-07-30 19:51:17 -04:00
David Zeuthen
dbf230991b Bug 625628 – GDBusProxy: wrong property name sorting
https://bugzilla.gnome.org/show_bug.cgi?id=625628

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-30 16:34:13 -04:00
David Zeuthen
aefc6df6bb Fix gschema-compile test
This was broken by commit 1b5b87bfa0

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-30 16:30:34 -04:00
David Zeuthen
d2d97a214d Bug 625584 – Crashes application on unref with signal subscription
Don't do too much work in the finalizer - in particular, there's no
need to send RemoveMatch() messages to the bus daemon since we're
going to sever the connection and the bus will garbage collect
anyway. In this case it crashed the process.

Also add a test case that checks that the appropriate GDestroyNotify
callbacks are called when unreffing a connection with either 1)
exported objects; 2) signal subscriptions or 3) filter functions
.. yes, ideally apps would unregister such callbacks before giving up
their ref but that's not how things work :-)

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-30 16:06:18 -04:00
Ryan Lortie
1b5b87bfa0 GSettings: Mark some strings for cat translation
<vuntz> *miaou*
2010-07-30 21:13:05 +02:00
David Zeuthen
14f17c1388 GDBusConnection: Fix up debug output when completing calls
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-30 11:40:00 -04:00
David Zeuthen
173977a701 GCredentials: use effective uid/gid
Otherwise e.g. setuid root processes can't connect to the system
bus. This was discovered when porting PolicyKit's pkexec(1) command to
a PolicyKit library using GDBus.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-30 11:26:43 -04:00
Eduardo Lima Mitev
8673f0b06c GIO: Add G-I annotations for several methods
Specifically:
 - g_io_stream_get_input/output_stream()
 - g_socket_client_get_local_address()
 - g_socket_connection_get_socket()
 - g_socket_listener_add_address()
 - g_socket_listener_accept_socket()
 - g_socket_listener_accept()
 - g_io_extension_point_get_extensions()
2010-07-29 14:06:00 +02:00
Owen Taylor
015df7e369 [gschema-compile] fix segfault
If files are passed on the command line and we don't set override_files
at all, don't try to read from the array.
2010-07-28 15:15:57 -04:00
David Zeuthen
19ef26c9c5 Use correct type for GDBusServer:active property
It's a boolean, not a string.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-28 12:58:04 -04:00
David Zeuthen
133e87ca87 GDBusConnection: Pass the GObject to g_simple_async_result_new()
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-28 12:51:09 -04:00
Ryan Lortie
a6f1bb4e17 Add support for vendor override files
You can drop a key-file in the schema directory that looks like:

[org.gtk.Example]
key='value'

to override the default value of 'key' in schema 'org.gtk.Example'.
2010-07-28 13:47:34 +02:00
Murray Cumming
633d9efc62 [gio]: gioenums.h: Remove trailing comma again. 2010-07-23 13:25:18 +02:00
Ryan Lortie
d5bd531d96 Cleanup the GSettingsBackend API
This is a substantial ABI break.  Rebuild dconf.
2010-07-22 18:39:50 -04:00
Ryan Lortie
aed440815e GSettings: add g_settings_reset()
Resets a key to its default value.
2010-07-22 17:50:05 -04:00
Benjamin Otte
dd1d1b3510 tests: Use GPOINTER_TO_SIZE() instead of just casting to guint
a) gcc doesn't like this ("Cast to pointer of different size)
b) It compares only half of the pointer
2010-07-22 21:56:20 +02:00
Benjamin Otte
284ea16b9d inotify: Constify function argument
gcc complained...
2010-07-22 21:56:20 +02:00
Ryan Lortie
dc7348b305 Fix very small leak in the GSettings test 2010-07-22 11:49:30 -04:00
Ryan Lortie
23a904fc15 Bug 624991 - GSettings mapping for G_TYPE_STRV
Added default mapping for G_TYPE_STRV based on a patch from Garrett
Regier.

Add a test case.
2010-07-22 11:34:57 -04:00
David Zeuthen
9b0a08449f GDBusAuthObserver: Fix docs
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-20 16:34:28 -04:00
David Zeuthen
7eba41346e Bug 617483 – Credentials passing
- Make GCredentials instance and class structures private so it can't
   be subclassed and we don't have to worry about ABI compat
   issues. This also allows us to get rid of the GCredentialsPrivate
   struct.

 - Add a GCredentialsType enumeration that is used whenever exchanging
   pointers with the user. This allows us to support OSes with
   multiple native credential types. In particular, it allows
   supporting OSes where the native credential evolves or even changes
   over time.

 - Add g_socket_get_credentials() method.

 - Add tests for g_socket_get_credentials(). Right now this is in the
   GDBus peer-to-peer test case but we can change that later.

 - Move GTcpConnection into a separate gtk-doc page as was already
   half-done with GUnixConnection. Also finish the GUnixConnection
   move and ensure send_credentials() and receive_credentials()
   methods are in the docs. Also nuke comment about GTcpConnection
   being empty compared to its superclass.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-20 16:34:18 -04:00
David Zeuthen
b3cf5cbd0b GDBusServer: Avoid handling incoming connections after stop() has been called
Without this fix, we'd sometimes run code after stop() and finalize()
to handle incoming requests. This was observed in the gdbus-peer test
case occasionally crashing:

 $ ./gdbus-peer
 /gdbus/peer-to-peer: OK
 /gdbus/delayed-message-processing: OK
 /gdbus/nonce-tcp:
 GLib-GObject-WARNING **: invalid uninstantiatable type `(null)' in cast to `GDBusServer'
 aborting...

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-20 12:14:30 -04:00
David Zeuthen
2be167f57c GDBus: Add support for D-Bus type 'h' (ie. G_VARIANT_TYPE_HANDLE)
This allows sending and receiving D-Bus messages with instances of the
'h' D-Bus type. Unlike libdbus-1's dbus_message_iter_get_basic()
method, g_variant_get_handle() does not return a duplicated unix file
descriptor (that must be closed with close(2)) - instead, it returns
an index that can be used to get/dup the file descriptor from a
GUnixFDList object that can be obtained from the GDBusMessage object.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-20 11:38:23 -04:00
Ryan Lortie
66388120d2 Move #include <sys/wait.h> down
Until after we include the glib stuff, so that we have G_OS_UNIX
defined.

For some reason <stdlib.h> pulls in <sys/wait.h> on Fedora so this
wasn't a problem, but many others have reported the issue.
2010-07-20 10:49:30 -04:00
David Zeuthen
493d8cb292 GDBus: Introduce G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL
This is preferable to the current magical solution whereby the serial
is only rewritten if non-zero. In particular, it makes it easier to
send the same message on multiple connections without having to reset
the serial number.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 17:05:28 -04:00
David Zeuthen
9d7b00638f GDBus: Forgot to add g_dbus_send_message_flags_get_type() to gio.symbols
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 16:11:20 -04:00
David Zeuthen
0b2b4deac5 GDBus: Add GDBusSendMessageFlags
This is currently unused but might be useful in the future. For
example, it might be nice with a way to bypass the current queue of
outgoing messages - having a flag enumeration allows us to add a
G_DBUS_SEND_MESSAGE_FLAGS_BYPASS_QUEUE etc. etc.

This commit breaks ABI and API. Users of the (rarely used) API to send
messages will have to port to this new API.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 16:07:57 -04:00
David Zeuthen
7190af4394 GDBus: Remove constness from introspection data structures
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 15:45:27 -04:00
David Zeuthen
4a1c5a1b98 GDBus: Add GDBusSignalFlags and use it in g_dbus_connection_signal_subscribe()
This is currently unused but will probably be useful in the
future. For example, we could have a _ARG0_IS_PATH to specify that
arg0 should be used for arg0path.

This commit breaks API and ABI. Users of
g_dbus_connection_signal_subscribe() will need to port to this new
version.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 15:05:10 -04:00