mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-25 13:14:14 +08:00
Implement D-Bus unregister watcher function
This commit is contained in:
parent
e4d4359c59
commit
5fa4b3d10f
@ -450,6 +450,11 @@ static void enable_final_measurement(struct thermometer *t)
|
||||
/* TODO: enable final measurements */
|
||||
}
|
||||
|
||||
static void disable_final_measurement(struct thermometer *t)
|
||||
{
|
||||
/* TODO: disable final measurements */
|
||||
}
|
||||
|
||||
static void watcher_exit(DBusConnection *conn, void *user_data)
|
||||
{
|
||||
/* TODO: Watcher disconnected */
|
||||
@ -510,9 +515,28 @@ static DBusMessage *register_watcher(DBusConnection *conn, DBusMessage *msg,
|
||||
static DBusMessage *unregister_watcher(DBusConnection *conn, DBusMessage *msg,
|
||||
void *data)
|
||||
{
|
||||
/* TODO: */
|
||||
return g_dbus_create_error(msg, ERROR_INTERFACE ".ThermometerError",
|
||||
"Function not implemented.");
|
||||
const gchar *sender = dbus_message_get_sender(msg);
|
||||
struct thermometer *t = data;
|
||||
struct watcher *watcher;
|
||||
gchar *path;
|
||||
|
||||
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
|
||||
DBUS_TYPE_INVALID))
|
||||
return btd_error_invalid_args(msg);
|
||||
|
||||
watcher = find_watcher(t, sender, path);
|
||||
if (watcher == NULL)
|
||||
return btd_error_does_not_exist(msg);
|
||||
|
||||
DBG("Thermometer watcher %s unregistered", path);
|
||||
|
||||
t->fwatchers = g_slist_remove(t->fwatchers, watcher);
|
||||
destroy_watcher(watcher);
|
||||
|
||||
if (g_slist_length(t->fwatchers) == 0)
|
||||
disable_final_measurement(t);
|
||||
|
||||
return dbus_message_new_method_return(msg);
|
||||
}
|
||||
|
||||
static DBusMessage *enable_intermediate(DBusConnection *conn, DBusMessage *msg,
|
||||
|
Loading…
Reference in New Issue
Block a user