diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2006-11-13 17:51:56 +0000 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2006-11-13 17:51:56 +0000 |
commit | e95363393f55072d43a0b5d70e11c790b4feecd4 (patch) | |
tree | 7aaf8944448f15e89c20841c174b79d6b2904dbc /input/input-service.c | |
parent | cc20b5c9b26dec7a97c922caa28f6ebf454f9c54 (diff) |
Call Register asynchronously
Diffstat (limited to 'input/input-service.c')
-rw-r--r-- | input/input-service.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/input/input-service.c b/input/input-service.c index d76ef74b..accb17c9 100644 --- a/input/input-service.c +++ b/input/input-service.c @@ -136,10 +136,27 @@ static const DBusObjectPathVTable input_table = { .message_function = input_message, }; -int input_dbus_init(void) +static void register_reply(DBusPendingCall *call, void *data) { + DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError err; - DBusMessage *msg, *reply; + + dbus_error_init(&err); + if (dbus_set_error_from_message(&err, reply)) { + error("Registering failed: %s", err.message); + dbus_error_free(&err); + raise(SIGTERM); + } + else + debug("Successfully registered"); + + dbus_message_unref(reply); +} + +int input_dbus_init(void) +{ + DBusMessage *msg; + DBusPendingCall *pending; const char *name = "Input service"; const char *description = "A service for input devices"; const char *input_path = INPUT_PATH; @@ -148,8 +165,6 @@ int input_dbus_init(void) if (!connection) return -1; - dbus_error_init(&err); - if (!dbus_connection_register_object_path(connection, input_path, &input_table, NULL)) { error("D-Bus failed to register %s path", INPUT_PATH); @@ -168,23 +183,14 @@ int input_dbus_init(void) DBUS_TYPE_STRING, &description, DBUS_TYPE_INVALID); - dbus_error_init(&err); - - reply = dbus_connection_send_with_reply_and_block(connection, msg, -1, - &err); - - dbus_message_unref(msg); - - if (!reply) { - error("Can't register service agent"); - if (dbus_error_is_set(&err)) { - error("%s", err.message); - dbus_error_free(&err); - } + if (!dbus_connection_send_with_reply(connection, msg, &pending, -1)) { + error("Sending Register method call failed"); + dbus_message_unref(msg); return -1; } - dbus_message_unref(reply); + dbus_pending_call_set_notify(pending, register_reply, NULL, NULL); + dbus_message_unref(msg); return 0; } |