From cab6bfb7ac40e0c5a39884ffa7620a2c278af314 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 17 Dec 2012 10:48:01 +0200 Subject: [PATCH] core: Add agent_get function --- src/agent.c | 14 ++++++++++++++ src/agent.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/agent.c b/src/agent.c index b7d506c1b..ea2f7e54c 100644 --- a/src/agent.c +++ b/src/agent.c @@ -211,6 +211,20 @@ void agent_unref(struct agent *agent) g_free(agent); } +struct agent *agent_get(const char *owner) +{ + struct agent *agent; + + agent = g_hash_table_lookup(agent_list, owner); + if (!agent) + agent = g_hash_table_lookup(agent_list, NULL); + + if (!agent) + return NULL; + + return agent_ref(agent); +} + struct agent *agent_create(struct btd_adapter *adapter, const char *name, const char *path, uint8_t capability, agent_remove_cb cb, void *remove_cb_data) diff --git a/src/agent.h b/src/agent.h index 769cd8234..9e70aa8c2 100644 --- a/src/agent.h +++ b/src/agent.h @@ -42,6 +42,8 @@ struct agent *agent_create(struct btd_adapter *adapter, const char *name, struct agent *agent_ref(struct agent *agent); void agent_unref(struct agent *agent); +struct agent *agent_get(const char *owner); + int agent_authorize_service(struct agent *agent, const char *path, const char *uuid, agent_cb cb, void *user_data, GDestroyNotify destroy); -- 2.47.3