diff -ur dbus-1.2.12/dbus/dbus-connection.c patched/dbus-1.2.12/dbus/dbus-connection.c --- dbus-1.2.12/dbus/dbus-connection.c 2008-08-07 20:44:36.000000000 +0200 +++ patched/dbus-1.2.12/dbus/dbus-connection.c 2009-01-30 18:22:51.000000000 +0100 @@ -3167,12 +3167,25 @@ * @returns #FALSE if no memory, #TRUE otherwise. * */ + +DBUS_DEPRECATED dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection, DBusMessage *message, DBusPendingCall **pending_return, int timeout_milliseconds) { + return dbus_connection_send_with_reply_setup (connection, message, pending_return, NULL, NULL, timeout_milliseconds); +} + +dbus_bool_t +dbus_connection_send_with_reply_setup (DBusConnection *connection, + DBusMessage *message, + DBusPendingCall **pending_return, + DBusPendingCallSetup pending_setup, + void *setup_user_data, + int timeout_milliseconds) +{ DBusPendingCall *pending; dbus_int32_t serial = -1; DBusDispatchStatus status; @@ -3181,6 +3194,11 @@ _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE); + if (pending_return && (!pending_setup)) + { + _dbus_warn ("Using **pending_return in dbus_connection_send_with_reply_setup() without pending_setup is deprecated and strongly discuraged\n"); + } + if (pending_return) *pending_return = NULL; @@ -3189,7 +3207,6 @@ if (!_dbus_connection_get_is_connected_unlocked (connection)) { CONNECTION_UNLOCK (connection); - return TRUE; } @@ -3213,7 +3230,7 @@ if (!_dbus_pending_call_set_timeout_error_unlocked (pending, message, serial)) goto error; - + /* Insert the serial in the pending replies hash; * hash takes a refcount on DBusPendingCall. * Also, add the timeout. @@ -3221,7 +3238,10 @@ if (!_dbus_connection_attach_pending_call_unlocked (connection, pending)) goto error; - + + if (pending_setup) + pending_setup(pending, setup_user_data); + if (!_dbus_connection_send_unlocked_no_update (connection, message, NULL)) { _dbus_connection_detach_pending_call_and_unlock (connection, @@ -3286,6 +3306,7 @@ * @returns the message that is the reply or #NULL with an error code if the * function fails. */ + DBusMessage* dbus_connection_send_with_reply_and_block (DBusConnection *connection, DBusMessage *message, @@ -4075,6 +4096,61 @@ dbus_connection_unref (connection); } +static void +_dbus_connection_update_dispatch_status (DBusConnection *connection, + DBusDispatchStatus new_status) +{ + dbus_bool_t changed; + DBusDispatchStatusFunction function; + void *data; + + HAVE_LOCK_CHECK (connection); + + _dbus_connection_ref_unlocked (connection); + + changed = new_status != connection->last_dispatch_status; + + connection->last_dispatch_status = new_status; + + function = connection->dispatch_status_function; + data = connection->dispatch_status_data; + + if (connection->disconnected_message_arrived && + !connection->disconnected_message_processed) + { + connection->disconnected_message_processed = TRUE; + + /* this does an unref, but we have a ref + * so we should not run the finalizer here + * inside the lock. + */ + connection_forget_shared_unlocked (connection); + + if (connection->exit_on_disconnect) + { + CONNECTION_UNLOCK (connection); + + _dbus_verbose ("Exiting on Disconnected signal\n"); + _dbus_exit (1); + _dbus_assert_not_reached ("Call to exit() returned"); + } + } + + /* We drop the lock */ + //CONNECTION_UNLOCK (connection); + + if (changed && function) + { + _dbus_verbose ("Notifying of change to dispatch status of %p now %d (%s)\n", + connection, new_status, + DISPATCH_STATUS_NAME (new_status)); + (* function) (connection, new_status, data); + } + + dbus_connection_unref (connection); +} + + /** * Gets the current state of the incoming message queue. * #DBUS_DISPATCH_DATA_REMAINS indicates that the message queue diff -ur dbus-1.2.12/dbus/dbus-connection.h patched/dbus-1.2.12/dbus/dbus-connection.h --- dbus-1.2.12/dbus/dbus-connection.h 2008-08-07 20:44:36.000000000 +0200 +++ patched/dbus-1.2.12/dbus/dbus-connection.h 2009-01-30 00:35:40.000000000 +0100 @@ -47,6 +47,7 @@ typedef struct DBusPreallocatedSend DBusPreallocatedSend; /** Opaque type representing a method call that has not yet received a reply. */ typedef struct DBusPendingCall DBusPendingCall; +typedef void (*DBusPendingCallSetup)(DBusPendingCall *pending, void *user_data); /** Opaque type representing a connection to a remote application and associated incoming/outgoing message queues. */ typedef struct DBusConnection DBusConnection; /** Set of functions that must be implemented to handle messages sent to a particular object path. */ @@ -199,10 +200,17 @@ dbus_bool_t dbus_connection_send (DBusConnection *connection, DBusMessage *message, dbus_uint32_t *client_serial); +DBUS_DEPRECATED dbus_bool_t dbus_connection_send_with_reply (DBusConnection *connection, DBusMessage *message, DBusPendingCall **pending_return, int timeout_milliseconds); +dbus_bool_t dbus_connection_send_with_reply_setup (DBusConnection *connection, + DBusMessage *message, + DBusPendingCall **pending_return, + DBusPendingCallSetup pending_setup, + void *setup_user_data, + int timeout_milliseconds); DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection, DBusMessage *message, int timeout_milliseconds,