diff options
Diffstat (limited to 'bus')
-rw-r--r-- | bus/activation.c | 4 | ||||
-rw-r--r-- | bus/connection.c | 20 | ||||
-rw-r--r-- | bus/dispatch.c | 36 | ||||
-rw-r--r-- | bus/driver.c | 29 | ||||
-rw-r--r-- | bus/test.c | 11 |
5 files changed, 51 insertions, 49 deletions
diff --git a/bus/activation.c b/bus/activation.c index a52fa4bc..91d3c116 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -586,7 +586,7 @@ bus_activation_service_created (BusActivation *activation, if (dbus_connection_get_is_connected (entry->connection)) { - message = dbus_message_new_reply (entry->activation_message); + message = dbus_message_new_method_return (entry->activation_message); if (!message) { BUS_SET_OOM (error); @@ -866,7 +866,7 @@ bus_activation_activate_service (BusActivation *activation, { _dbus_verbose ("Service \"%s\" is already active\n", service_name); - message = dbus_message_new_reply (activation_message); + message = dbus_message_new_method_return (activation_message); if (!message) { diff --git a/bus/connection.c b/bus/connection.c index 5121658d..e588039e 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -963,18 +963,18 @@ bus_connection_preallocate_oom_error (DBusConnection *connection) if (preallocated == NULL) return FALSE; - /* d->name may be NULL, but that is OK */ - message = dbus_message_new (DBUS_ERROR_NO_MEMORY, - d->name); + message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); + if (message == NULL) { dbus_connection_free_preallocated_send (connection, preallocated); return FALSE; } - dbus_message_set_is_error (message, TRUE); - - if (!dbus_message_set_sender (message, + /* d->name may be NULL, but that is OK */ + if (!dbus_message_set_name (message, DBUS_ERROR_NO_MEMORY) || + !dbus_message_set_destination (message, d->name) || + !dbus_message_set_sender (message, DBUS_SERVICE_DBUS)) { dbus_connection_free_preallocated_send (connection, preallocated); @@ -1338,7 +1338,7 @@ bus_transaction_send (BusTransaction *transaction, DBusList *link; _dbus_verbose (" trying to add %s %s to transaction%s\n", - dbus_message_get_is_error (message) ? "error" : + dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ? "error" : dbus_message_get_reply_serial (message) != 0 ? "reply" : "message", dbus_message_get_name (message), @@ -1554,9 +1554,9 @@ bus_transaction_send_error_reply (BusTransaction *transaction, _dbus_verbose ("Sending error reply %s \"%s\"\n", error->name, error->message); - reply = dbus_message_new_error_reply (in_reply_to, - error->name, - error->message); + reply = dbus_message_new_error (in_reply_to, + error->name, + error->message); if (reply == NULL) return FALSE; diff --git a/bus/dispatch.c b/bus/dispatch.c index d43e8121..f4d19dcf 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -674,8 +674,8 @@ check_hello_message (BusContext *context, acquired = NULL; message = NULL; - message = dbus_message_new (DBUS_MESSAGE_HELLO, - DBUS_SERVICE_DBUS); + message = dbus_message_new_method_call (DBUS_MESSAGE_HELLO, + DBUS_SERVICE_DBUS); if (message == NULL) return TRUE; @@ -725,7 +725,7 @@ check_hello_message (BusContext *context, goto out; } - if (dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) { if (dbus_message_has_name (message, DBUS_ERROR_NO_MEMORY)) @@ -906,8 +906,8 @@ check_nonexistent_service_activation (BusContext *context, dbus_error_init (&error); - message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE, - DBUS_SERVICE_DBUS); + message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE, + DBUS_SERVICE_DBUS); if (message == NULL) return TRUE; @@ -953,7 +953,7 @@ check_nonexistent_service_activation (BusContext *context, _dbus_verbose ("Received %s on %p\n", dbus_message_get_name (message), connection); - if (dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) { if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS)) { @@ -1287,8 +1287,8 @@ check_send_exit_to_service (BusContext *context, retval = FALSE; /* Kill off the test service by sending it a quit message */ - message = dbus_message_new ("org.freedesktop.DBus.TestSuiteExit", - service_name); + message = dbus_message_new_method_call ("org.freedesktop.DBus.TestSuiteExit", + service_name); if (message == NULL) { @@ -1324,7 +1324,7 @@ check_send_exit_to_service (BusContext *context, /* see if we got an error during message bus dispatching */ bus_test_run_clients_loop (FALSE); message = dbus_connection_borrow_message (connection); - got_error = message != NULL && dbus_message_get_is_error (message); + got_error = message != NULL && dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR; if (message) { dbus_connection_return_message (connection, message); @@ -1344,7 +1344,7 @@ check_send_exit_to_service (BusContext *context, message = pop_message_waiting_for_memory (connection); _dbus_assert (message != NULL); - if (!dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR) { _dbus_warn ("expecting an error reply to asking test service to exit, got %s\n", dbus_message_get_name (message)); @@ -1402,7 +1402,7 @@ check_got_error (BusContext *context, goto out; } - if (!dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) != DBUS_MESSAGE_TYPE_ERROR) { _dbus_warn ("Expected an error, got %s\n", dbus_message_get_name (message)); @@ -1460,8 +1460,8 @@ check_existent_service_activation (BusContext *context, dbus_error_init (&error); - message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE, - DBUS_SERVICE_DBUS); + message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE, + DBUS_SERVICE_DBUS); if (message == NULL) return TRUE; @@ -1513,7 +1513,7 @@ check_existent_service_activation (BusContext *context, dbus_message_get_name (message), connection, DBUS_MESSAGE_ACTIVATE_SERVICE); - if (dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) { if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS)) { @@ -1563,7 +1563,7 @@ check_existent_service_activation (BusContext *context, } got_service_deleted = dbus_message_has_name (message, DBUS_MESSAGE_SERVICE_DELETED); - got_error = dbus_message_get_is_error (message); + got_error = dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR; dbus_connection_return_message (connection, message); message = NULL; @@ -1668,8 +1668,8 @@ check_segfault_service_activation (BusContext *context, dbus_error_init (&error); - message = dbus_message_new (DBUS_MESSAGE_ACTIVATE_SERVICE, - DBUS_SERVICE_DBUS); + message = dbus_message_new_method_call (DBUS_MESSAGE_ACTIVATE_SERVICE, + DBUS_SERVICE_DBUS); if (message == NULL) return TRUE; @@ -1716,7 +1716,7 @@ check_segfault_service_activation (BusContext *context, _dbus_verbose ("Received %s on %p\n", dbus_message_get_name (message), connection); - if (dbus_message_get_is_error (message)) + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR) { if (!dbus_message_has_sender (message, DBUS_SERVICE_DBUS)) { diff --git a/bus/driver.c b/bus/driver.c index e0afd8ef..6e0024b0 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -49,8 +49,8 @@ bus_driver_send_service_deleted (const char *service_name, _dbus_verbose ("sending service deleted: %s\n", service_name); - message = dbus_message_new (DBUS_MESSAGE_SERVICE_DELETED, - DBUS_SERVICE_BROADCAST); + message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_DELETED); + if (message == NULL) { BUS_SET_OOM (error); @@ -83,8 +83,8 @@ bus_driver_send_service_created (const char *service_name, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - message = dbus_message_new (DBUS_MESSAGE_SERVICE_CREATED, - DBUS_SERVICE_BROADCAST); + message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_CREATED); + if (message == NULL) { BUS_SET_OOM (error); @@ -123,15 +123,16 @@ bus_driver_send_service_lost (DBusConnection *connection, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - message = dbus_message_new (DBUS_MESSAGE_SERVICE_LOST, - bus_connection_get_name (connection)); + message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_LOST); + if (message == NULL) { BUS_SET_OOM (error); return FALSE; } - if (!dbus_message_append_args (message, + if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) || + !dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, DBUS_TYPE_INVALID)) { @@ -163,8 +164,7 @@ bus_driver_send_service_acquired (DBusConnection *connection, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - message = dbus_message_new (DBUS_MESSAGE_SERVICE_ACQUIRED, - bus_connection_get_name (connection)); + message = dbus_message_new_signal (DBUS_MESSAGE_SERVICE_ACQUIRED); if (message == NULL) { @@ -172,7 +172,8 @@ bus_driver_send_service_acquired (DBusConnection *connection, return FALSE; } - if (!dbus_message_append_args (message, + if (!dbus_message_set_destination (message, bus_connection_get_name (connection)) || + !dbus_message_append_args (message, DBUS_TYPE_STRING, service_name, DBUS_TYPE_INVALID)) { @@ -343,7 +344,7 @@ bus_driver_send_welcome_message (DBusConnection *connection, name = bus_connection_get_name (connection); _dbus_assert (name != NULL); - welcome = dbus_message_new_reply (hello_message); + welcome = dbus_message_new_method_return (hello_message); if (welcome == NULL) { BUS_SET_OOM (error); @@ -387,7 +388,7 @@ bus_driver_handle_list_services (DBusConnection *connection, registry = bus_connection_get_registry (connection); - reply = dbus_message_new_reply (message); + reply = dbus_message_new_method_return (message); if (reply == NULL) { BUS_SET_OOM (error); @@ -463,7 +464,7 @@ bus_driver_handle_acquire_service (DBusConnection *connection, error)) goto out; - reply = dbus_message_new_reply (message); + reply = dbus_message_new_method_return (message); if (reply == NULL) { BUS_SET_OOM (error); @@ -518,7 +519,7 @@ bus_driver_handle_service_exists (DBusConnection *connection, _dbus_string_init_const (&service_name, name); service = bus_registry_lookup (registry, &service_name); - reply = dbus_message_new_reply (message); + reply = dbus_message_new_method_return (message); if (reply == NULL) { BUS_SET_OOM (error); @@ -107,6 +107,10 @@ client_disconnect_handler (DBusMessageHandler *handler, DBusMessage *message, void *user_data) { + if (!dbus_message_has_name (message, + DBUS_MESSAGE_LOCAL_DISCONNECT)) + return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + _dbus_verbose ("Removing client %p in disconnect handler\n", connection); @@ -138,7 +142,6 @@ dbus_bool_t bus_setup_debug_client (DBusConnection *connection) { DBusMessageHandler *disconnect_handler; - const char *to_handle[] = { DBUS_MESSAGE_LOCAL_DISCONNECT }; dbus_bool_t retval; disconnect_handler = dbus_message_handler_new (client_disconnect_handler, @@ -147,10 +150,8 @@ bus_setup_debug_client (DBusConnection *connection) if (disconnect_handler == NULL) return FALSE; - if (!dbus_connection_register_handler (connection, - disconnect_handler, - to_handle, - _DBUS_N_ELEMENTS (to_handle))) + if (!dbus_connection_add_filter (connection, + disconnect_handler)) { dbus_message_handler_unref (disconnect_handler); return FALSE; |