~jamesodhunt/ubuntu/raring/upstart/1.6

« back to all changes in this revision

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

  • Committer: Scott James Remnant
  • Date: 2010-02-04 23:39:59 UTC
  • mfrom: (1182.1.45 upstart)
  • mto: This revision was merged to the branch mainline in revision 1250.
  • Revision ID: scott@netsplit.com-20100204233959-7kajqjnaoh7208ob
Tags: upstream-0.6.5
ImportĀ upstreamĀ versionĀ 0.6.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
void
2
 
my_com_netsplit_Nih_Test_property_set_notify (DBusPendingCall *   pending_call,
3
 
                                              NihDBusPendingData *pending_data)
4
 
{
5
 
        DBusMessage *   reply;
6
 
        DBusMessageIter iter;
7
 
        NihDBusMessage *message;
8
 
        DBusError       error;
9
 
 
10
 
        nih_assert (pending_call != NULL);
11
 
        nih_assert (pending_data != NULL);
12
 
 
13
 
        nih_assert (dbus_pending_call_get_completed (pending_call));
14
 
 
15
 
        /* Steal the reply from the pending call. */
16
 
        reply = dbus_pending_call_steal_reply (pending_call);
17
 
        nih_assert (reply != NULL);
18
 
 
19
 
        /* Handle error replies */
20
 
        if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
21
 
                message = NIH_MUST (nih_dbus_message_new (pending_data, pending_data->connection, reply));
22
 
 
23
 
                dbus_error_init (&error);
24
 
                dbus_set_error_from_message (&error, message->message);
25
 
 
26
 
                nih_error_push_context ();
27
 
                nih_dbus_error_raise (error.name, error.message);
28
 
                pending_data->error_handler (pending_data->data, message);
29
 
                nih_error_pop_context ();
30
 
 
31
 
                dbus_error_free (&error);
32
 
                nih_free (message);
33
 
                dbus_message_unref (reply);
34
 
                return;
35
 
        }
36
 
 
37
 
        nih_assert (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_METHOD_RETURN);
38
 
 
39
 
        /* Create a message context for the reply, and check
40
 
         * there are no arguments.
41
 
         */
42
 
        message = NIH_MUST (nih_dbus_message_new (pending_data, pending_data->connection, reply));
43
 
        dbus_message_iter_init (message->message, &iter);
44
 
 
45
 
        if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_INVALID) {
46
 
                nih_error_push_context ();
47
 
                nih_error_raise (NIH_DBUS_INVALID_ARGS,
48
 
                                 _(NIH_DBUS_INVALID_ARGS_STR));
49
 
                pending_data->error_handler (pending_data->data, message);
50
 
                nih_error_pop_context ();
51
 
 
52
 
                nih_free (message);
53
 
                dbus_message_unref (reply);
54
 
                return;
55
 
        }
56
 
 
57
 
        /* Call the handler function */
58
 
        if (pending_data->handler) {
59
 
                nih_error_push_context ();
60
 
                ((MySetPropertyReply)pending_data->handler) (pending_data->data, message);
61
 
                nih_error_pop_context ();
62
 
        }
63
 
 
64
 
        nih_free (message);
65
 
        dbus_message_unref (reply);
66
 
}