2
my_test_method (NihDBusProxy * proxy,
5
MyTestMethodReply handler,
6
NihDBusErrorHandler error_handler,
10
DBusMessage * method_call;
12
DBusPendingCall * pending_call;
13
NihDBusPendingData *pending_data;
15
nih_assert (proxy != NULL);
16
nih_assert (str != NULL);
17
nih_assert ((handler == NULL) || (error_handler != NULL));
19
/* Construct the method call message. */
20
method_call = dbus_message_new_method_call (proxy->name, proxy->path, "com.netsplit.Nih.Test", "TestMethod");
22
nih_return_no_memory_error (NULL);
24
dbus_message_set_auto_start (method_call, proxy->auto_start);
26
dbus_message_iter_init_append (method_call, &iter);
28
/* Marshal a char * onto the message */
29
if (! dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str)) {
30
dbus_message_unref (method_call);
31
nih_return_no_memory_error (NULL);
34
/* Marshal a int32_t onto the message */
35
if (! dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &flags)) {
36
dbus_message_unref (method_call);
37
nih_return_no_memory_error (NULL);
40
/* Handle a fire-and-forget message */
41
if (! error_handler) {
42
dbus_message_set_no_reply (method_call, TRUE);
43
if (! dbus_connection_send (proxy->connection, method_call, NULL)) {
44
dbus_message_unref (method_call);
45
nih_return_no_memory_error (NULL);
48
dbus_message_unref (method_call);
49
return (DBusPendingCall *)TRUE;
52
/* Send the message and set up the reply notification. */
53
pending_data = nih_dbus_pending_data_new (NULL, proxy->connection,
54
(NihDBusReplyHandler)handler,
57
dbus_message_unref (method_call);
58
nih_return_no_memory_error (NULL);
62
if (! dbus_connection_send_with_reply (proxy->connection, method_call,
63
&pending_call, timeout)) {
64
dbus_message_unref (method_call);
65
nih_free (pending_data);
66
nih_return_no_memory_error (NULL);
69
dbus_message_unref (method_call);
71
NIH_MUST (dbus_pending_call_set_notify (pending_call, (DBusPendingCallNotifyFunction)my_com_netsplit_Nih_Test_TestMethod_notify,
72
pending_data, (DBusFreeFunction)nih_discard));