Commit Graph

168 Commits

Author SHA1 Message Date
Lucas De Marchi 8c634044ed gdbus: Add properties into Introspectable interface 2012-11-26 12:54:05 +01:00
Lucas De Marchi d87dcb6c5b gdbus: Implement DBus.Properties.Set method
Contrary to Get() and GetAll(), Set() is asynchronous so we pass an id
to the setter so later it can declare the Set() as successful or
otherwise.
2012-11-26 12:53:40 +01:00
Lucas De Marchi 1b7afd7b1e gdbus: Implement DBus.Properties.GetAll method 2012-11-26 12:53:23 +01:00
Lucas De Marchi 337e908edd gdbus: Implement DBus.Properties.Get method 2012-11-26 12:52:56 +01:00
Lucas De Marchi 1315c48085 gdbus: Add skeleton of DBus.Properties interface
This interface is responsible for handling properties of all objects in
a given path. Right now it only registers itself, doing nothing useful.
A conversion to this new layout will be done by subsequent patches.

org.freedesktop.org.DBus.Properties spec can be found at
http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties
2012-11-26 12:52:23 +01:00
Lucas De Marchi cb44357b67 gdbus: Use macros to add annotations
Besides being more readable this way it avoids going over 80 chars.
2012-11-26 12:51:53 +01:00
Lucas De Marchi 0e1baf1997 gdbus: Move typedefs up
Move the typedefs up so they can be used by functions and callbacks.
2012-11-26 12:51:29 +01:00
Luiz Augusto von Dentz 320096a7da gdbus: Fix not freeing list node by using g_slist_delete_link
g_slist_remove_link does not free the node which can cause leaks so
replace that with g_slist_delete_link which does free memory properly.
2012-10-31 16:18:58 -05:00
Lucas De Marchi 19cb623390 gdbus: Refactor filter_data_find()
Now this function is only used for searching the listeners of a
connection and the other parameters are not needed anymore.
2012-10-31 16:18:53 -05:00
Lucas De Marchi 5236c01a31 gdbus: Fix wrong signal handler match
When we add a signal handler with g_dbus_add_signal_watch(), this
function tries to multiplex the matches added in libdbus by checking
if there's a previous filter_data with the same fields. However, if the
field is NULL it accepts as being the same. The result is that the
following watches will use the same filter data:

watch1 = g_dbus_add_signal_watch(conn, BUS_NAME, NULL, iface, member,
						cb1, data1, NULL);
watch2 = g_dbus_add_signal_watch(conn, BUS_NAME, "/path2", iface, member,
						cb2, data2, NULL);
watch3 = g_dbus_add_signal_watch(conn, BUS_NAME, "/path3", iface, member,
						cb3, data3, NULL);

The result is that when a signal arrives with path == "/path2", all 3
callbacks above will be called, with the same signal delivered to all of
them.

Another problem is that, if we invert the calls like below, only signals
to cb1 will never be trigerred, nonetheless it used path == NULL.

watch2 = g_dbus_add_signal_watch(conn, BUS_NAME, "/path2", iface, member,
						cb2, data2, NULL);
watch1 = g_dbus_add_signal_watch(conn, BUS_NAME, NULL, iface, member,
						cb1, data1, NULL);
watch3 = g_dbus_add_signal_watch(conn, BUS_NAME, "/path3", iface, member,
						cb3, data3, NULL);

This is fixed by not multiplexing the matchs with filter data if any of
the fields are different, including being NULL. When a signal arrives,
if a field is NULL we accept it as a match, but not when adding the
signal handler.
2012-10-31 16:18:45 -05:00
Johan Hedberg 5033e06844 gdbus: Fix crash when getting disconnected from the bus
When getting disconnected from the bus sometimes (maybe always?)
dbus_watch_handle() can cause the "info" context to be free'd meaning
that we should not try to access it after the call. The only member we
need access to is the connection pointer and as the code already has a
ref() call for it it's only natural to solve the issue by adding a local
variable not dependent on "info".

The backtrace of the crash fixed looks as follows:

 Invalid read of size 8
   at 0x121085: watch_func (mainloop.c:105)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
 Address 0x5bbcd90 is 16 bytes inside a block of size 24 free'd
   at 0x4A079AE: free (vg_replace_malloc.c:427)
   by 0x4C7837E: g_free (gmem.c:252)
   by 0x4F708BF: dbus_watch_set_data (dbus-watch.c:614)
   by 0x4F70938: _dbus_watch_unref (dbus-watch.c:132)
   by 0x4F6E9A7: _dbus_transport_handle_watch (dbus-transport.c:884)
   by 0x4F59AFB: _dbus_connection_handle_watch (dbus-connection.c:1497)
   by 0x4F70AF9: dbus_watch_handle (dbus-watch.c:683)
   by 0x121084: watch_func (mainloop.c:103)
   by 0x4C72694: g_main_context_dispatch (gmain.c:2539)
   by 0x4C729C7: g_main_context_iterate.isra.23 (gmain.c:3146)
   by 0x4C72DC1: g_main_loop_run (gmain.c:3340)
   by 0x120541: main (main.c:551)
2012-10-31 16:18:41 -05:00
Jaganath Kanakkassery c1cea66a5e gdbus: Fix compilation error if macro "error" is defined
The variable "signature" used in error is not defined and "args" is now
a struct instead of a string.
2012-08-27 17:28:42 -07:00
Lucas De Marchi daca27425f gdbus: Fix removal of filter after last filter_data
If there's a signal watch that's also watching for name
(data->name_watch) currently we are trying to remove the message_filter
twice since we may have the following call chain:

filter_data_remove_callback()
  filter_data_free()
    g_dbus_remove_watch()
      filter_data_remove_callback()
	filter_data_free()
        dbus_connection_remove_filter()
  dbus_connection_remove_filter()

Because of this we can't currently watch for signals passing the bus
name. After this patch we don't have this issue anymore.

We fix it by removing the filter before calling filter_data_free() if we
are the last filter_data and thus avoid calling
dbus_connection_remove_filter() twice.
2012-06-30 10:39:11 +02:00
Mikel Astiz ce395cd818 gdbus: Fix incorrectly discarded signals
Signals with no arguments were incorrectly filtered out due to the NULL
inequality check.
2012-05-22 20:27:56 +02:00
Lucas De Marchi 4fa967e7e2 gdbus: do not check signature twice
Message signature is already checked in generic_message(), so there's no
need to check again in the callback.
2012-05-20 02:47:57 -07:00
Lucas De Marchi e400426267 gdbus: add Method.NoReply annotation in introspection 2012-05-20 02:47:57 -07:00
Lucas De Marchi e42130a83b gdbus: add Deprecated annotation in introspection 2012-05-20 02:47:57 -07:00
Lucas De Marchi 7f2b69d7b8 gdbus: remove signature and reply from tables 2012-05-20 02:47:57 -07:00
Lucas De Marchi ce3345e21d gdbus: loop over args to check message signature 2012-05-20 02:47:57 -07:00
Lucas De Marchi 568a7d0707 gdbus: use GDBusArgInfo to generate introspection
By using GDBusArgInfo in methods and signals, the introspection
generation is much simpler and we can add each argument name.
2012-05-20 02:47:57 -07:00
Lucas De Marchi 8e815c100b gdbus: add and use helpers for table declarations 2012-05-20 02:47:57 -07:00
Lucas De Marchi d1a1a9bcc9 gdbus: add argument info to methods and signals 2012-05-20 02:47:56 -07:00
Marcel Holtmann addd756348 gdbus: Constify introspection method table 2012-05-17 19:58:02 -07:00
Lucas De Marchi 37805e0197 gdbus: do not call memset for terminating NUL 2012-05-17 19:58:01 -07:00
Lucas De Marchi a77fcca3c6 gdbus: return if method signature is malformed 2012-05-17 19:58:01 -07:00
Marcel Holtmann 9d789c57d7 gdbus: Remove unneeded NEED_DBUS_WATCH_GET_UNIX_FD check 2012-04-16 17:57:08 +02:00
Anderson Lizardo 9b26016a24 gdbus: Use destroy callback for service watch
Even though service watches accepted a "destroy" callback, they were
being ignored. This fix properly pass them along so they are called when
the watch is removed.
2012-04-05 08:07:35 -07:00
Syam Sidhardhan 2f232f8b02 gdbus: Fix white space coding style issue
- corrected the space before '{'
2012-04-05 08:07:28 -07:00
Szymon Janc ecd56f7a07 gdbus: Remove unused result variable from g_dbus_pending_success 2011-05-27 09:53:38 -07:00
Grant Erickson e37fcb4af3 gdbus: Unconditionally remove D-Bus timeouts
Address an issue in which the daemon incorrectly handles D-Bus main
loop timeouts by only removing timeouts that are not enabled when
D-Bus requests a timeout removal.
2011-03-09 13:32:32 -08:00
Daniel Wagner 1ef27ffe86 gdbus: Remove root node 'name' attribute in introspection
generate_introspection_xml generates the root <node> tags with a
'name' attribute. This seems to be a valid attribute but it is not
consistent with the way the D-Bus daemon generates empty nodes.

For example if we register "/foo/bar", D-Bus daemon will generate for
"/foo" a introspection which looks like this:

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <node name="bar"/>
</node>

and generate_introspection_xml generates for "/foo/bar":

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/foo/bar">
</node>

Just don't add the 'name' attribute to the root node.  The GLib
binding for D-Bus does it the same way.
2011-01-19 17:25:30 +01:00
Daniel Wagner 28ec0e2174 gdbus: invaldate_parent_data: walk the whole path down
Assume there is only one object registerd at "/". If we add a new
object at "/foo/bar" the introspection of "/" has to be updated. A new
node has to be added at "/".

invalidate_parent_data stops invaldating the whole path because the
boolean return value of dbus_connection_get_object_path_data is used
wrong.

If we get a TRUE just go on down in the path, if FALSE is return
dbus_connection_get_object_path_data has run out of memory.
2011-01-19 17:25:30 +01:00
Marcel Holtmann e5120c96e9 gdbus: Update copyright information 2011-01-01 17:32:29 -08:00
Johan Hedberg a437bfba54 gdbus: fix accessing freed callback data
cb->disc_func or cb->conn_func could remove the callback so this needs
to be checked for before continuing processing.
2010-12-10 00:07:53 +01:00
Lucas De Marchi 752a2ccec8 gdbus: explicitly compare pointers to NULL
This patch was generated by the following semantic patch
(http://coccinelle.lip6.fr/)

// <smpl>
@fix disable is_null,isnt_null1@
expression *E;
@@

- !E
+ E == NULL
// </smpl>
2010-12-08 16:33:06 +01:00
Luiz Augusto von Dentz c896d11724 gdbus: fix not handling bus disconnects
We where not dispatching data when a bus disconnects which cause
Disconnected signal to not be processed and thus causing the process to
either not exit or to not trigger callbacks registered with
g_dbus_set_disconnect_function.

To fix this now we always schedule a dispatch which will make sure data
still not processed will make its way to the proper handlers even if
disconnected.
2010-10-13 15:55:26 +03:00
Marcel Holtmann f02dd45e0b Add support for builtin GDBus security using PolicyKit 2010-09-09 18:26:37 +02:00
Marcel Holtmann e173173a1f Add support for GDBus security action and flags 2010-09-09 18:26:36 +02:00
Marcel Holtmann 679f17303d Use simpler error callbacks for GDBus security hooks 2010-09-09 18:26:36 +02:00
Marcel Holtmann 8ef8135a2a Add support for GDBus security handlers 2010-09-09 18:26:36 +02:00
Luiz Augusto von Dentz fbf3bcd87d Fix calling watch callbacks after it has been removed
Pending call should be removed if the watch is removed since the
application no longer expect that to be reached and may already freed the
data associated with it.
2010-09-08 18:28:23 +02:00
Luiz Augusto Von Dentz 79e5dc585d Fix signal watch when a service name is given
The bus name should be resolved when adding a watch by service name since
messages do always come with sender set to owner's bus name, also it
should listen to owner updates since it can change without invalidating
the watch.
2010-09-08 18:28:23 +02:00
Luiz Augusto Von Dentz 93d5bd6af8 Do not automatically remove watches for service names
Services can be owned again so it is perfectly fine to keep the watch.
2010-09-08 18:28:23 +02:00
Marcel Holtmann f261f38fd9 Add printf format attribute for error creation helper 2010-08-19 19:35:04 +02:00
Zhenhua Zhang 04fffa93a1 Free service data in service_reply
Avoid the memory leak of server_data.
2010-07-26 07:30:48 -07:00
Johan Hedberg 58b37ddb53 Fix parent path introspection data invalidation for multiple levels
In the case that parent path data needs to be invalidated we shouldn't
stop at the immediate parent if it doesn't have our own handler
registered but should continue upwards in the tree until we reach root
or our own handler.
2010-04-30 00:30:54 +02:00
Johan Hedberg 3f2494a7b0 Fix memory leak in g_dbus_register_interface 2010-04-29 23:46:12 +02:00
Marcel Holtmann ab5dcea4fd Make interface callback tables const 2010-03-07 14:33:09 -08:00
Vinicius Costa Gomes a181ec319b Fix the case when the requested name is already in use
We weren't setting the dbus error in this situation.
2010-03-07 14:32:03 -08:00
Vinicius Costa Gomes 2e9a16ce07 Fix: a pending call was leaking in check_service
This was triggering an assert inside libdbus when the timeout inside
the leaking pending call expired. The assert said that we were trying
to remove an nonexistent timeout.
2010-02-17 01:59:31 -08:00
Marcel Holtmann 4c6497e317 Remove unneeded use of status variable 2010-01-27 09:50:24 +01:00
Forrest Zhao 57013cfa0d Introduce g_dbus_setup_private() to gdbus
g_dbus_setup_private() is used to setup private DBusConnection
2010-01-27 09:50:24 +01:00
Luiz Augusto Von Dentz a6fc21fd1f Fix regression when removing watches
filter_data_find return the first data registered in this case so there is
no guarantee that it return the same data as passed to
filter_data_remove_callback which is the one that should be removed.

The fix is to simple cache the connection removing the correct data before
checking if there is any filter left.
2010-01-08 04:24:09 -08:00
Marcel Holtmann 436c2a7c63 Cleanup of D-Bus mainloop integration 2010-01-02 21:43:22 -08:00
Marcel Holtmann 8e0de054cd Update copyright information of D-Bus helper library 2010-01-01 17:05:57 -08:00
Luiz Augusto Von Dentz 71ac4f60d9 Fix undefined symbols 2009-12-29 17:37:35 -08:00
Luiz Augusto Von Dentz d897b24085 Port gdbus to use g_dbus_add_signal_watch 2009-12-29 01:19:38 -08:00
Luiz Augusto Von Dentz e8111c8229 Add initial implementation of g_dbus_add_signal_watch
With g_dbus_add_signal_watch there is no need to register multiple filters
for dbus nor add matching rules manually.
2009-12-29 01:19:38 -08:00
Daniel Orstadius 9c688fff68 Fix D-Bus timeout handling
Timeouts should also be removed in the remove_timeout callback in
addition to the timeout_handler_free function. This is how dbus-glib
does it and it seems to prevent crashes in certain situations.
2009-12-16 22:34:33 -08:00
Claudio Takahasi dab8e45d2e Fix message handling for autostart.
Current implementation of libdbus Request name is blocking, consequently
the first incomming message that triggered the service autostart is not
being processed properly.
2009-10-29 22:49:50 +09:00
RISKÓ Gergely df7313d301 gdbus: handle introspection generally in generic_message.
Previously it was a specific case, now introspection is just another
interface, which is always implemented.  It is registered/unregistered
when an object path is referenced first/last.
2009-09-24 10:22:19 -07:00
RISKÓ Gergely e72d349483 Add introspection interface to the output of introspection calls
This provides better compatibility with some D-Bus clients, such as qdbus.
2009-09-14 14:08:07 -07:00
Marcel Holtmann 70aab2a826 Convert to fully non-recursive build system 2009-08-24 23:49:40 -07:00
Johan Hedberg b8addb4af3 Use NameHasOwner instead of ListNames for name checking 2009-08-08 10:34:08 -07:00
Marcel Holtmann 2520e26820 Fix blocking service watch initial connect handling 2009-08-06 22:13:09 -07:00
Denis Kenzior 50ff91e209 Make the parent path invalidateable 2009-05-11 11:50:45 -07:00
Luiz Augusto von Dentz 5106f7a8cf Fix crash when calling g_dbus_remove_watch from watch callback 2009-05-06 13:55:09 -07:00
Marcel Holtmann 7851155b80 Add D-Bus helper library for GLib integration 2009-04-26 20:51:36 +02:00