Commit Graph

45 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz dae225a0d6 gdbus: Make GDBusClient work without ObjectManager
This makes GDBusClient work normally without ObjectManager.
2015-03-26 10:02:05 +01:00
Arman Uguray 97ac3f7c76 gdbus/client: Allow specifying ObjectManager path
GDBusClient currently hard-codes "/" as the remote ObjectManager path.
This is generally incorrect, as an application can choose to expose an
ObjectManager at any well-known path. This patch fixes this by allowing
the user to pass in the ObjectManager path by introducing a new
conctructor "g_dbus_client_new_full".
2015-03-26 10:02:05 +01:00
Arman Uguray 26a00f2f31 gdbus/client: Don't GetManagedObjects w/o handlers
The client code currently issues GetManagedObjects if new handlers are
set via g_dbus_client_set_proxy_handlers. An application may set these
to NULL before unref'ing a client or to simply prevent further events.
Hence, there is no need to refresh objects or properties if all handlers
are NULL.
2015-03-26 10:02:05 +01:00
Arman Uguray 8660527b11 gdbus: Don't refresh objects/props if disconnected
If g_dbus_client_set_proxy_handlers gets called from within a
proxy_removed callback, the code may end up refreshing the proxy's
properties and incorrectly access the client's proxy_list as it gets
freed. This patch fixes this, so that get_managed_objects does nothing
if it gets called during a service disconnect.
2015-02-22 19:42:25 +01:00
Claudio Takahasi 9aeea028ed gdbus: Avoid reporting GDBusClient disconnect twice
No matter if disconnection was reported previously, g_dbus_client_unref()
was always calling service disconnect callback. This patch fix the
following scenario:
1) service disconnects from the bus
2) disconnect callback gets called
3) client calls g_dbus_client_unref(), disconnect callback is called
   again.
2014-09-08 05:48:48 +02:00
Claudio Takahasi 6fdcfc309c gdbus: Add g_dbus_proxy_set_property_array
This patch adds a new gdbus utility function to allow setting a property
of fixed, and non-fixed values array.
2014-03-24 14:27:51 -07:00
Claudio Takahasi ea2b34eacd gdbus: Add g_dbus_client_set_ready_watch()
This patch adds a new gdbus helper to notify the clients that
GetManagedObjects reply was received and the last proxy has been
informed previously by the proxy_added callback.
2014-03-06 09:36:48 -08:00
Szymon Janc 2d925003a4 gdbus: Remove not needed check for NULL DBusPendingCall
It is now checked by g_dbus_send_message_with_reply() so there is no
need to double check that in caller.
2013-10-14 06:06:31 -07:00
Luiz Augusto von Dentz 2e5938f3bb gdbus/client: Use g_dbus_add_properties_watch to track properties
This make the handling much simpler and avoids duplicates of the same
match rule.
2013-09-12 08:25:23 -07:00
Luiz Augusto von Dentz 607c1e088d gdbus/client: Use g_dbus_add_signal_watch to track signals
This make the handling much simpler and avoids duplicates of the same
match rule.
2013-09-12 08:25:23 -07:00
Luiz Augusto von Dentz cb5f10d2c2 gdbus/client: Use g_dbus_add_service_watch to track services
This make the handling much simpler and avoids duplicates of the same
match rule.
2013-09-12 08:25:23 -07:00
Luiz Augusto von Dentz 1ad938a5fd gdbus: Avoid calling dbus_connection_send*
dbus_connection_send* should not be called directly except by
g_dbus_send_message.
2013-09-10 19:07:28 -07:00
Henrique Dante de Almeida 2e2b588a46 gdbus: Remove proxies when client disconnects
Remove proxies and generate proxy_removed callbacks even when there are
no corresponding InterfaceRemoved signals.

This patch fixes having zombie gdbus proxy object when a server
disconnects without sending InterfaceRemoved signals. These objects
may interact with new server instances, for example, making
InterfaceAdded signals of new objects with the same name be filtered
out as duplicated, or staying allocated, but unused, if the new server
doesn't reuse the object paths. Note that as a side-effect, the
lifetime of a gdbus proxy becomes stricter: it lives at most for the
duration of a single connection to a single instance of a server
process.
2013-06-19 08:11:35 +02:00
Anderson Lizardo 1c75edf59a gdbus: Fix using NULL DBusPendingCall when disconnected from D-Bus
From D-Bus documentation for dbus_connection_send_with_reply():

"Warning: if the connection is disconnected or you try to send Unix file
descriptors on a connection that does not support them, the
DBusPendingCall will be set to NULL, so be careful with this."

Fix these errors when killing D-Bus daemon with the client still
running:

process 5712: arguments to dbus_pending_call_set_notify() were
incorrect, assertion "pending != NULL" failed in file
../../dbus/dbus-pending-call.c line 596.
This is normally a bug in some application using the D-Bus library.
process 5712: arguments to dbus_pending_call_unref() were incorrect,
assertion "pending != NULL" failed in file
../../dbus/dbus-pending-call.c line 572.
This is normally a bug in some application using the D-Bus library.
2013-05-08 11:28:11 +02:00
Anderson Lizardo 4059dd878c gdbus: Fix segfault when D-Bus daemon exits
Fix this crash if D-Bus exits while the client is still connected to it:

==5570== Invalid read of size 1
==5570==    at 0x402D28E: strcmp (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==5570==    by 0x4070E22: g_str_equal (ghash.c:1704)
==5570==    by 0x8055F61: message_filter (client.c:1123)
==5570==    by 0x4141500: dbus_connection_dispatch (in
/lib/i386-linux-gnu/libdbus-1.so.3.5.8)
==5570==    by 0x80506F7: message_dispatch (mainloop.c:76)
==5570==    by 0x4081A7E: g_timeout_dispatch (gmain.c:3882)
==5570==    by 0x4080D85: g_main_context_dispatch (gmain.c:2539)
==5570==    by 0x4081124: g_main_context_iterate.isra.21 (gmain.c:3146)
==5570==    by 0x408156A: g_main_loop_run (gmain.c:3340)
==5570==    by 0x41BF4D2: (below main) (libc-start.c:226)
==5570==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5570==
==5570==
2013-05-08 11:28:11 +02:00
Luiz Augusto von Dentz 0ecd3562a0 gdbus: Fix calling GetManagedObjects twice in a row
Calling g_dbus_client_new followed by g_dbus_client_set_proxy_handlers
cause two calls to GetManagedObjects in a row as GetNameOwner reply is
asyncronously it triggers the second call because the handlers have
been set by g_dbus_client_set_proxy_handlers.
2013-05-03 23:43:06 -07:00
Luiz Augusto von Dentz dcf4ccb947 gdbus: Fix not calling property_changed callback
In case a property did not appear by the time proxy_added was called
property_changed has to be called if it appear latter otherwise the
application will be unaware of it.
2013-04-08 20:09:51 -07:00
Lucas De Marchi de4aa7266b gdbus: Use gcc builtin instead of g_atomic
g_atomic_* end up using G_STATIC_ASSERT, causing gcc 4.8 to yell due to
-Wunused-local-typedefs.

gdbus/client.c: In function ‘g_dbus_client_ref’:
/usr/include/glib-2.0/glib/gmacros.h:162:53: error: typedef ‘_GStaticAssertCompileTimeAssertion_2’ locally defined but not used [-Werror=unused-local-typedefs]
 #define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1]
2013-04-08 20:07:37 -07:00
Denis Kenzior 1d4d3f1fb9 gdbus: Add g_dbus_proxy_set_removed_watch 2013-02-14 08:47:10 -06:00
Marcel Holtmann 8910e64f84 gdbus: Don't call property changed callback during client init
When the client uses ObjectManager to init properties, do not call
property changed callbacks. They should only be called once the proxy
added has been successfully signaled since the proxy itself provides
a full copy of available properties.
2013-02-11 20:22:42 +01:00
Marcel Holtmann 7738e3a92c gdbus: Hold client reference during get name owner reply 2013-01-02 07:37:35 -08:00
Marcel Holtmann 2f3da9cdf4 gdbus: Update properties on D-Bus client re-connections 2012-12-29 14:49:38 -08:00
Marcel Holtmann f9f6536b2b gdbus: Add function to manually refresh properties 2012-12-29 14:49:38 -08:00
Marcel Holtmann 816c028a94 gdbus: Add support for proxy property change notifications 2012-12-29 14:49:38 -08:00
Marcel Holtmann d3899c7af6 gdbus: Fix handling of client connect/disconnect signals 2012-12-29 14:49:38 -08:00
Marcel Holtmann cdd1febd4d gdbus: Protect standalone proxy creation with client reference 2012-12-29 14:49:37 -08:00
Marcel Holtmann 9ba681ddcd gdbus: Use object manager only if callback functions are set 2012-12-27 23:59:19 -08:00
Marcel Holtmann 91e3369a38 gdbus: Use client service name and not hardcoded org.bluez 2012-12-27 23:59:19 -08:00
Marcel Holtmann 8bef871cff gdbus: Add support for creating D-Bus proxies without object manager 2012-12-27 23:59:19 -08:00
Marcel Holtmann d1bd840d2e gdbus: Avoid using g_ptr_array_new_full convenience function
The g_ptr_array_new_full function only got introduced with GLib 2.30
and to avoid requiring a newer GLib use g_ptr_array_set_free_func instead.
2012-12-22 12:09:58 -08:00
Marcel Holtmann fcab2080be gdbus: Increase the method call timeout to 5 minutes 2012-12-19 03:50:43 +01:00
Marcel Holtmann 5de077a604 gdbus: Fix race condition with creating duplicate client proxies 2012-12-19 03:50:42 +01:00
Marcel Holtmann 4a0cab2f85 gdbus: Fix issue with unref of client while parsing interfaces 2012-12-19 03:50:42 +01:00
Marcel Holtmann c3d3a3a661 gdbus: Fix issue with unref of client in connect handler 2012-12-19 03:50:42 +01:00
Marcel Holtmann 33ff02e3a4 gdbus: Add support for D-Bus client method calls 2012-12-19 03:50:42 +01:00
Marcel Holtmann 90c719f29c gdbus: Add callback support for handling property changes 2012-12-19 03:50:42 +01:00
Marcel Holtmann f40f27cd44 gdbus: Handle property changed signals and update property 2012-12-19 03:50:42 +01:00
Marcel Holtmann 64103f35a1 gdbus: Set property changed filter match rule for each proxy 2012-12-19 03:50:42 +01:00
Marcel Holtmann ec448e4d36 gdbus: Use a GPtrArray for the match rules 2012-12-19 03:50:42 +01:00
Marcel Holtmann 7ba21da7f3 gdbus: Add support for setting D-Bus client basic properties 2012-12-19 03:50:42 +01:00
Marcel Holtmann 37a3708928 gdbus: Deep copy of variants also requires a signature 2012-12-19 03:50:42 +01:00
Marcel Holtmann ada304fb01 gdbus: Add support for complex D-Bus client properties 2012-12-19 03:50:42 +01:00
Marcel Holtmann 8ec0dab7fa gdbus: Add support for D-Bus client properties 2012-12-19 03:50:42 +01:00
Marcel Holtmann b30177d961 gdbus: Add support for D-Bus client proxies 2012-12-19 03:50:42 +01:00
Marcel Holtmann 8d5bb26e43 gdbus: Add helper functions for simple D-Bus clients 2012-12-19 03:50:42 +01:00