2
my_test_method (NihDBusProxy * proxy,
3
MyTestMethodReply handler,
4
NihDBusErrorHandler error_handler,
8
DBusMessage * method_call;
10
DBusPendingCall * pending_call;
11
NihDBusPendingData *pending_data;
13
nih_assert (proxy != NULL);
14
nih_assert ((handler == NULL) || (error_handler != NULL));
16
/* Construct the method call message. */
17
method_call = dbus_message_new_method_call (proxy->name, proxy->path, "com.netsplit.Nih.Test", "TestMethod");
19
nih_return_no_memory_error (NULL);
21
dbus_message_set_auto_start (method_call, proxy->auto_start);
23
dbus_message_iter_init_append (method_call, &iter);
25
/* Handle a fire-and-forget message */
26
if (! error_handler) {
27
dbus_message_set_no_reply (method_call, TRUE);
28
if (! dbus_connection_send (proxy->connection, method_call, NULL)) {
29
dbus_message_unref (method_call);
30
nih_return_no_memory_error (NULL);
33
dbus_message_unref (method_call);
34
return (DBusPendingCall *)TRUE;
37
/* Send the message and set up the reply notification. */
38
pending_data = nih_dbus_pending_data_new (NULL, proxy->connection,
39
(NihDBusReplyHandler)handler,
42
dbus_message_unref (method_call);
43
nih_return_no_memory_error (NULL);
47
if (! dbus_connection_send_with_reply (proxy->connection, method_call,
48
&pending_call, timeout)) {
49
dbus_message_unref (method_call);
50
nih_free (pending_data);
51
nih_return_no_memory_error (NULL);
54
dbus_message_unref (method_call);
56
NIH_MUST (dbus_pending_call_set_notify (pending_call, (DBusPendingCallNotifyFunction)my_com_netsplit_Nih_Test_TestMethod_notify,
57
pending_data, (DBusFreeFunction)nih_discard));