diff options
author | Ulisses Furquim <ulissesf@gmail.com> | 2006-10-26 13:46:50 +0000 |
---|---|---|
committer | Ulisses Furquim <ulissesf@gmail.com> | 2006-10-26 13:46:50 +0000 |
commit | ded45f72aa06a1c4613000b822d7e9b0f75c59e3 (patch) | |
tree | f5788b4b214204827bf82e60b314913db4d7820d /hcid/dbus-manager.c | |
parent | 148cf3ccb516f70cafcb3d72946ea141c2b7d86e (diff) |
Add signals to report when a service is registered or unregistered
Diffstat (limited to 'hcid/dbus-manager.c')
-rw-r--r-- | hcid/dbus-manager.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c index 3f6a0a4e..518a0d35 100644 --- a/hcid/dbus-manager.c +++ b/hcid/dbus-manager.c @@ -218,10 +218,11 @@ static DBusHandlerResult list_services(DBusConnection *conn, static DBusHandlerResult register_service(DBusConnection *conn, DBusMessage *msg, void *data) { + DBusMessage *message; const char *path; DBusError err; int reg_err; - + dbus_error_init(&err); dbus_message_get_args(msg, &err, DBUS_TYPE_STRING, &path, @@ -232,17 +233,26 @@ static DBusHandlerResult register_service(DBusConnection *conn, dbus_error_free(&err); return error_invalid_arguments(conn, msg); } - /* FIXME: send a signal to notify the new registered service? */ - reg_err = register_service_agent(conn, dbus_message_get_sender(msg), path); + + reg_err = register_service_agent(conn, dbus_message_get_sender(msg), + path); if (reg_err < 0) return error_failed(conn, msg, -reg_err); + /* Report that a new service was registered */ + message = dbus_message_new_signal(BASE_PATH, MANAGER_INTERFACE, + "ServiceRegistered"); + dbus_message_append_args(message, DBUS_TYPE_STRING, &path, + DBUS_TYPE_INVALID); + send_message_and_unref(conn, message); + return send_message_and_unref(conn, dbus_message_new_method_return(msg)); } static DBusHandlerResult unregister_service(DBusConnection *conn, DBusMessage *msg, void *data) { + DBusMessage *message; const char *path; DBusError err; int unreg_err; @@ -258,10 +268,18 @@ static DBusHandlerResult unregister_service(DBusConnection *conn, return error_invalid_arguments(conn, msg); } - unreg_err = unregister_service_agent(conn, dbus_message_get_sender(msg), path); + unreg_err = unregister_service_agent(conn, + dbus_message_get_sender(msg), path); if (unreg_err < 0) return error_failed(conn, msg, -unreg_err); + /* Report that the service was unregistered */ + message = dbus_message_new_signal(BASE_PATH, MANAGER_INTERFACE, + "ServiceUnregistered"); + dbus_message_append_args(message, DBUS_TYPE_STRING, &path, + DBUS_TYPE_INVALID); + send_message_and_unref(conn, message); + return send_message_and_unref(conn, dbus_message_new_method_return(msg)); } |