2
my_async_method_reply (NihDBusMessage *message,
3
const int32_t * output,
8
DBusMessageIter output_iter;
10
nih_assert (message != NULL);
11
nih_assert ((output_len == 0) || (output != NULL));
13
/* If the sender doesn't care about a reply, don't bother wasting
14
* effort constructing and sending one.
16
if (dbus_message_get_no_reply (message->message))
19
/* Construct the reply message. */
20
reply = dbus_message_new_method_return (message->message);
24
dbus_message_iter_init_append (reply, &iter);
26
/* Marshal an array onto the message */
27
if (! dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "i", &output_iter)) {
28
dbus_message_unref (reply);
32
for (size_t output_i = 0; output_i < output_len; output_i++) {
33
int32_t output_element;
35
output_element = output[output_i];
37
/* Marshal a int32_t onto the message */
38
if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_INT32, &output_element)) {
39
dbus_message_iter_abandon_container (&iter, &output_iter);
40
dbus_message_unref (reply);
45
if (! dbus_message_iter_close_container (&iter, &output_iter)) {
46
dbus_message_unref (reply);
50
/* Send the reply, appending it to the outgoing queue. */
51
if (! dbus_connection_send (message->connection, reply, NULL)) {
52
dbus_message_unref (reply);
56
dbus_message_unref (reply);