From 2ca6e95764dc3491458dcf077ce77cbbabf00ddf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 6 Jul 2005 21:27:53 +0000 Subject: 2005-07-06 Colin Walters * dbus/dbus-glib.h (DBusGPendingCall, DBusGPendingCallNotify) (DBUS_TYPE_G_PENDING_CALL, dbus_g_pending_call_get_g_type) (dbus_g_pending_call_ref, dbus_g_pending_call_unref): Delete. (dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete in favor of dbus_g_proxy_begin_call and dbus_g_proxy_cancel_call. (DBusGProxyCall, DBusGProxyCallNotify): New. (dbus_g_proxy_begin_call): Change prototype to take callback, user data, and destroy function. This replaces dbus_g_pending_call_set_notify. (dbus_g_proxy_cancel_call): Prototype. (DBusGAsyncData): Delete, shouldn't be needed anymore. * glib/dbus-gproxy.c (struct _DBusGProxy): Add call_id_counter and pending_calls map. (struct _DBusGProxyManager): Add bus_proxy member, which is an internal proxy for calls to the bus. Remove pending_nameowner_calls, now the internal proxy keeps track. (dbus_g_proxy_manager_unref): Unref bus proxy, remove reference to pending_nameowner_calls. (got_name_owner_cb): Update prototype, and use dbus_g_proxy_end_call. (got_name_owner_cb): Remove reference to pending_nameowner_calls. (dbus_g_proxy_manager_register): Delete directly libdbus code in favor of using internal proxy. (dbus_g_proxy_manager_unregister): Update to use dbus_g_proxy_cancel_call for any pending GetNameOwner call. (dbus_g_proxy_init): Initialize pending calls map. (dbus_g_proxy_constructor): New. (dbus_g_proxy_class_init): Add get/set property functions, constructor, and add NAME, PATH, and INTERFACE properties. (cancel_pending_call): New function. (dbus_g_proxy_dispose): Iterate over any outstanding calls and cancel them. (dbus_g_proxy_set_property, dbus_g_proxy_get_property): New. (GPendingNotifyClosure): New structure. (d_pending_call_notify, d_pending_call_free): Moved here from dbus-glib.c. (DBUS_G_VALUE_ARRAY_COLLECT_ALL): Moved around to satisfy function ordering. (manager_begin_bus_call): New internal function for talking to internal bus proxy. (dbus_g_proxy_new): Construct object using GObjet properties. (dbus_g_proxy_begin_call_internal): Update to take user data, etc. Create closure of same, and insert call into map of pending calls. (dbus_g_proxy_end_call_internal): Take call id instead of pending call. Look up pending call in current set. Remove it when we've completed. (dbus_g_pending_call_end, dbus_g_proxy_end_call_internal): Delete. (dbus_g_proxy_begin_call): Change API to take callback, user data, and destroy function directly. (dbus_g_proxy_end_call): Update to take DBusGProxyCall. (dbus_g_proxy_call): Invoke with NULL callback. (dbus_g_proxy_cancel_call): New function, replaces dbus_g_pending_call_cancel. * glib/dbus-gparser.c (validate_signature): Fix call to dbus_set_g_error. * glib/dbus-gobject.c (dbus_g_object_type_dbus_metadata_quark): New quark for attaching metadata to GType. (info_hash): Delete. (lookup_object_info): Look up using quark. (dbus_g_object_type_install_info): Check that a type is classed, not that it's an object. Also just install type data using quark instead of using global hash. * glib/dbus-glib.c (dbus_g_pending_call_ref) (dbus_g_pending_call_unref, dbus_pending_call_get_g_type) (GPendingNotifyClosure): Delete. (d_pending_call_notify, d_pending_call_free): Move to dbus-gproxy.c. (dbus_g_pending_call_set_notify, dbus_g_pending_call_cancel): Delete. * glib/dbus-binding-tool-glib.c (generate_client_glue): Disable async client method generation until we can fix it... * tools/dbus-viewer.c (load_child_nodes): Use dbus_g_proxy_call. (load_from_service_thread_func): Ditto. * tools/dbus-names-model.c (struct NamesModel): Hold DBusGProxyCall. (have_names_notify): Update prototype, use dbus_g_proxy_cancel_call. (names_model_reload): Update for new dbus_g_proxy_begin_call API. * tools/dbus-monitor.c (filter_func): Update for print_message API change. * test/glib/test-dbus-glib.c: Add more tests for async invocations. Update many begin_call/end_call pairs to just use dbus_g_proxy_call. * tools/dbus-send.c (main): Add --print-reply=literal mode. This allows us to dump print-introspect.c. * tools/dbus-print-message.h (print_message): Add literal argument to print_message which is intended to allow printing arguments without metadata like "string=". * tools/dbus-print-message.c (print_iter): Add literal argument. (print_message): Allow printing string messages literally. --- glib/dbus-glib.c | 140 ------------------------------------------------------- 1 file changed, 140 deletions(-) (limited to 'glib/dbus-glib.c') diff --git a/glib/dbus-glib.c b/glib/dbus-glib.c index 5b30ce7a..5dbcdf08 100644 --- a/glib/dbus-glib.c +++ b/glib/dbus-glib.c @@ -111,30 +111,6 @@ dbus_g_message_unref (DBusGMessage *gmessage) dbus_message_unref (c); } -/** - * Increments refcount on a pending call. - * - * @param call the call - * @returns the same call - */ -DBusGPendingCall* -dbus_g_pending_call_ref (DBusGPendingCall *call) -{ - dbus_pending_call_ref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call)); - return call; -} - -/** - * Decrements refcount on a pending call. - * - * @param call the call - */ -void -dbus_g_pending_call_unref (DBusGPendingCall *call) -{ - dbus_pending_call_unref (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call)); -} - /** * The implementation of DBUS_GERROR error domain. See documentation * for GError in GLib reference manual. @@ -234,24 +210,6 @@ dbus_message_get_g_type (void) return our_type; } -/** - * Get the GLib type ID for a DBusPendingCall boxed type. - * - * @returns GLib type - */ -GType -dbus_pending_call_get_g_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static ("DBusPendingCall", - (GBoxedCopyFunc) dbus_pending_call_ref, - (GBoxedFreeFunc) dbus_pending_call_unref); - - return our_type; -} - /** * Get the GLib type ID for a DBusGConnection boxed type. * @@ -288,24 +246,6 @@ dbus_g_message_get_g_type (void) return our_type; } -/** - * Get the GLib type ID for a DBusGPendingCall boxed type. - * - * @returns GLib type - */ -GType -dbus_g_pending_call_get_g_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static ("DBusGPendingCall", - (GBoxedCopyFunc) dbus_g_pending_call_ref, - (GBoxedFreeFunc) dbus_g_pending_call_unref); - - return our_type; -} - /** * Get the DBusConnection corresponding to this DBusGConnection. * The return value does not have its refcount incremented. @@ -330,86 +270,6 @@ dbus_g_message_get_message (DBusGMessage *gmessage) return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage); } -typedef struct -{ - DBusGPendingCallNotify func; - void *data; - GDestroyNotify free_data_func; -} GPendingNotifyClosure; - -static void -d_pending_call_notify (DBusPendingCall *dcall, - void *data) -{ - GPendingNotifyClosure *closure = data; - DBusGPendingCall *gcall = DBUS_G_PENDING_CALL_FROM_PENDING_CALL (dcall); - - (* closure->func) (gcall, closure->data); -} - -static void -d_pending_call_free (void *data) -{ - GPendingNotifyClosure *closure = data; - - if (closure->free_data_func) - (* closure->free_data_func) (closure->data); - - g_free (closure); -} - -/** - * Sets up a notification to be invoked when the pending call - * is ready to be ended without blocking. - * You can call dbus_g_proxy_end_call() at any time, - * but it will block if no reply or error has been received yet. - * This function lets you handle the reply asynchronously. - * - * @param call the pending call - * @param callback the callback - * @param callback_data data for the callback - * @param free_data_func free the callback data with this - */ -void -dbus_g_pending_call_set_notify (DBusGPendingCall *call, - DBusGPendingCallNotify callback, - void *callback_data, - GDestroyNotify free_data_func) -{ - GPendingNotifyClosure *closure; - DBusPendingCall *dcall; - - g_return_if_fail (callback != NULL); - - closure = g_new (GPendingNotifyClosure, 1); - - closure->func = callback; - closure->data = callback_data; - closure->free_data_func = free_data_func; - - dcall = DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call); - dbus_pending_call_set_notify (dcall, d_pending_call_notify, - closure, - d_pending_call_free); -} - -/** - * Cancels a pending call. Does not affect the reference count - * of the call, but it means you will never be notified of call - * completion, and can't call dbus_g_proxy_end_call(). - * - * @param call the call - */ -void -dbus_g_pending_call_cancel (DBusGPendingCall *call) -{ - DBusPendingCall *dcall; - - dcall = DBUS_PENDING_CALL_FROM_G_PENDING_CALL (call); - - dbus_pending_call_cancel (dcall); -} - /** @} */ /* end of public API */ -- cgit