2
my_com_netsplit_Nih_Test_Method_notify (DBusPendingCall * pending_call,
3
NihDBusPendingData *pending_data)
7
NihDBusMessage * message;
9
MyMethodStructure *structure;
10
DBusMessageIter structure_iter;
11
const char * structure_item0_dbus;
12
char * structure_item0;
13
uint32_t structure_item1;
15
nih_assert (pending_call != NULL);
16
nih_assert (pending_data != NULL);
18
nih_assert (dbus_pending_call_get_completed (pending_call));
20
/* Steal the reply from the pending call. */
21
reply = dbus_pending_call_steal_reply (pending_call);
22
nih_assert (reply != NULL);
24
/* Handle error replies */
25
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
26
message = NIH_MUST (nih_dbus_message_new (pending_data, pending_data->connection, reply));
28
dbus_error_init (&error);
29
dbus_set_error_from_message (&error, message->message);
31
nih_error_push_context ();
32
nih_dbus_error_raise (error.name, error.message);
33
pending_data->error_handler (pending_data->data, message);
34
nih_error_pop_context ();
36
dbus_error_free (&error);
38
dbus_message_unref (reply);
42
nih_assert (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN);
47
/* Create a message context for the reply, and iterate
50
message = nih_dbus_message_new (pending_data, pending_data->connection, reply);
54
dbus_message_iter_init (message->message, &iter);
56
/* Demarshal a structure from the message */
57
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_STRUCT) {
58
nih_error_push_context ();
59
nih_error_raise (NIH_DBUS_INVALID_ARGS,
60
_(NIH_DBUS_INVALID_ARGS_STR));
61
pending_data->error_handler (pending_data->data, message);
62
nih_error_pop_context ();
65
dbus_message_unref (reply);
69
dbus_message_iter_recurse (&iter, &structure_iter);
71
structure = nih_new (message, MyMethodStructure);
78
/* Demarshal a char * from the message */
79
if (dbus_message_iter_get_arg_type (&structure_iter) != DBUS_TYPE_STRING) {
81
nih_error_push_context ();
82
nih_error_raise (NIH_DBUS_INVALID_ARGS,
83
_(NIH_DBUS_INVALID_ARGS_STR));
84
pending_data->error_handler (pending_data->data, message);
85
nih_error_pop_context ();
88
dbus_message_unref (reply);
92
dbus_message_iter_get_basic (&structure_iter, &structure_item0_dbus);
94
structure_item0 = nih_strdup (structure, structure_item0_dbus);
95
if (! structure_item0) {
102
dbus_message_iter_next (&structure_iter);
104
structure->item0 = structure_item0;
106
/* Demarshal a uint32_t from the message */
107
if (dbus_message_iter_get_arg_type (&structure_iter) != DBUS_TYPE_UINT32) {
108
nih_free (structure);
109
nih_error_push_context ();
110
nih_error_raise (NIH_DBUS_INVALID_ARGS,
111
_(NIH_DBUS_INVALID_ARGS_STR));
112
pending_data->error_handler (pending_data->data, message);
113
nih_error_pop_context ();
116
dbus_message_unref (reply);
120
dbus_message_iter_get_basic (&structure_iter, &structure_item1);
122
dbus_message_iter_next (&structure_iter);
124
structure->item1 = structure_item1;
126
if (dbus_message_iter_get_arg_type (&structure_iter) != DBUS_TYPE_INVALID) {
127
nih_free (structure);
128
nih_error_push_context ();
129
nih_error_raise (NIH_DBUS_INVALID_ARGS,
130
_(NIH_DBUS_INVALID_ARGS_STR));
131
pending_data->error_handler (pending_data->data, message);
132
nih_error_pop_context ();
135
dbus_message_unref (reply);
139
dbus_message_iter_next (&iter);
141
if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID) {
142
nih_error_push_context ();
143
nih_error_raise (NIH_DBUS_INVALID_ARGS,
144
_(NIH_DBUS_INVALID_ARGS_STR));
145
pending_data->error_handler (pending_data->data, message);
146
nih_error_pop_context ();
149
dbus_message_unref (reply);
153
enomem: __attribute__ ((unused));
156
/* Call the handler function */
157
if (pending_data->handler) {
158
nih_error_push_context ();
159
((MyMethodReply)pending_data->handler) (pending_data->data, message, structure);
160
nih_error_pop_context ();
164
dbus_message_unref (reply);