Diff between ddceeef03eba855e03db3f781c2e3b7f0c06036c and cab6bfb7ac40e0c5a39884ffa7620a2c278af314

Changed Files

File Additions Deletions Status
src/agent.c +14 -0 modified
src/agent.h +2 -0 modified

Full Patch

diff --git a/src/agent.c b/src/agent.c
index b7d506c..ea2f7e5 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 769cd82..9e70aa8 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);