~jamesodhunt/ubuntu/raring/upstart/1.6

« back to all changes in this revision

Viewing changes to nih-dbus-tool/tests/expected/test_method_proxy_function_deprecated.c

  • Committer: Scott James Remnant
  • Date: 2010-02-04 23:59:00 UTC
  • mfrom: (1185.1.9 upstream)
  • Revision ID: scott@netsplit.com-20100204235900-c0j0frow10azwsus
* New upstream release:
  - libnih has been separated out into its own project.
  - "start on" and "stop on" now support != matches.  LP: #513035.
  - Fixed crash in child when unable to spawn job.  LP: #451917.
  - No longer holds /dev/console open so SAK won't kill init.  LP: #486005.
  - Added missing OPTIONS section to init(8).  LP: #449883.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
DBusPendingCall *
2
 
my_test_method (NihDBusProxy *      proxy,
3
 
                const char *        str,
4
 
                int32_t             flags,
5
 
                MyTestMethodReply   handler,
6
 
                NihDBusErrorHandler error_handler,
7
 
                void *              data,
8
 
                int                 timeout)
9
 
{
10
 
        DBusMessage *       method_call;
11
 
        DBusMessageIter     iter;
12
 
        DBusPendingCall *   pending_call;
13
 
        NihDBusPendingData *pending_data;
14
 
 
15
 
        nih_assert (proxy != NULL);
16
 
        nih_assert (str != NULL);
17
 
        nih_assert ((handler == NULL) || (error_handler != NULL));
18
 
 
19
 
        /* Construct the method call message. */
20
 
        method_call = dbus_message_new_method_call (proxy->name, proxy->path, "com.netsplit.Nih.Test", "TestMethod");
21
 
        if (! method_call)
22
 
                nih_return_no_memory_error (NULL);
23
 
 
24
 
        dbus_message_set_auto_start (method_call, proxy->auto_start);
25
 
 
26
 
        dbus_message_iter_init_append (method_call, &iter);
27
 
 
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);
32
 
        }
33
 
 
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);
38
 
        }
39
 
 
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);
46
 
                }
47
 
 
48
 
                dbus_message_unref (method_call);
49
 
                return (DBusPendingCall *)TRUE;
50
 
        }
51
 
 
52
 
        /* Send the message and set up the reply notification. */
53
 
        pending_data = nih_dbus_pending_data_new (NULL, proxy->connection,
54
 
                                                  (NihDBusReplyHandler)handler,
55
 
                                                  error_handler, data);
56
 
        if (! pending_data) {
57
 
                dbus_message_unref (method_call);
58
 
                nih_return_no_memory_error (NULL);
59
 
        }
60
 
 
61
 
        pending_call = 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);
67
 
        }
68
 
 
69
 
        dbus_message_unref (method_call);
70
 
 
71
 
        NIH_MUST (dbus_pending_call_set_notify (pending_call, (DBusPendingCallNotifyFunction)my_com_netsplit_Nih_Test_TestMethod_notify,
72
 
                                                pending_data, (DBusFreeFunction)nih_discard));
73
 
 
74
 
        return pending_call;
75
 
}