void btd_agent_cleanup(void) { g_dbus_unregister_interface(btd_get_dbus_connection(), "/org/bluez", "org.bluez.AgentManager1"); set_default_agent(NULL); g_hash_table_destroy(agent_list); }
static void agent_disconnect(DBusConnection *conn, void *user_data) { struct agent *agent = user_data; DBG("Agent %s disconnected", agent->owner); if (agent->watch > 0) { g_dbus_remove_watch(conn, agent->watch); agent->watch = 0; } if (agent == default_agent) set_default_agent(NULL); g_hash_table_remove(agent_list, agent->owner); }
static void agent_unref_debug(struct connman_agent *agent, const char *file, int line, const char *caller) { DBG("%p ref %d by %s:%d:%s()", agent, agent->refcount - 1, file, line, caller); if (__sync_fetch_and_sub(&agent->refcount, 1) != 1) return; cancel_all_requests(agent); g_free(agent->owner); g_free(agent->path); if (agent == default_agent) { default_agent = NULL; set_default_agent(); } g_free(agent); }
int connman_agent_register(const char *sender, const char *path) { struct connman_agent *agent; DBG("sender %s path %s", sender, path); agent = g_hash_table_lookup(agent_hash, sender); if (agent) return -EEXIST; agent = agent_create(sender, path); if (!agent) return -EINVAL; DBG("agent %s", agent->owner); g_hash_table_replace(agent_hash, agent->owner, agent); if (!default_agent) set_default_agent(); return 0; }
static DBusMessage *request_default(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct agent *agent; const char *sender, *path; sender = dbus_message_get_sender(msg); agent = g_hash_table_lookup(agent_list, sender); if (!agent) return btd_error_does_not_exist(msg); if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID) == FALSE) return btd_error_invalid_args(msg); if (g_str_equal(path, agent->path) == FALSE) return btd_error_does_not_exist(msg); set_default_agent(agent); return dbus_message_new_method_return(msg); }