Exemple #1
0
static DBusMessage *unregister_watcher(DBusConnection *conn,
						DBusMessage *msg, void *data)
{
	const char *sender = dbus_message_get_sender(msg);
	struct gatt_service *gatt = data;
	struct watcher *watcher, *match;
	GSList *l;
	char *path;

	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
							DBUS_TYPE_INVALID))
		return btd_error_invalid_args(msg);

	match = g_new0(struct watcher, 1);
	match->name = g_strdup(sender);
	match->path = g_strdup(path);
	l = g_slist_find_custom(gatt->watchers, match, watcher_cmp);
	INFO("unregistering watcher %s",match->path);
	watcher_free(match);
	if (!l)
		return btd_error_not_authorized(msg);


	watcher = l->data;
	g_dbus_remove_watch(conn, watcher->id);
	gatt->watchers = g_slist_remove(gatt->watchers, watcher);
	watcher_free(watcher);

	if (gatt->watchers == NULL && gatt->attioid) {
		btd_device_remove_attio_callback(gatt->dev, gatt->attioid);
		gatt->attioid = 0;
	}

	return dbus_message_new_method_return(msg);
}
Exemple #2
0
/**
 * Cancel monitoring of specified file.
 */
void
watcher_unregister(const char *filename)
{
	struct monitored *m;

	m = hikset_lookup(monitored, filename);

	g_assert(m != NULL);

	hikset_remove(monitored, m->filename);
	watcher_free(m);
}