mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 13:02:44 +01:00
agent: utilize IWD_MODULE
Converts agent into an IWD module. This removes the dbus dependency on agent. Since dbus is initialized very early we can assume dbus_get_bus is going to return a valid object.
This commit is contained in:
parent
1382c4724a
commit
046fe96537
19
src/agent.c
19
src/agent.c
@ -29,6 +29,7 @@
|
||||
#include <ell/ell.h>
|
||||
#include "src/dbus.h"
|
||||
#include "src/agent.h"
|
||||
#include "src/iwd.h"
|
||||
|
||||
static unsigned int next_request_id = 0;
|
||||
|
||||
@ -619,8 +620,10 @@ static bool release_agent(void *data, void *user_data)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool agent_init(struct l_dbus *dbus)
|
||||
static int agent_init(void)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
|
||||
agents = l_queue_new();
|
||||
|
||||
if (!l_dbus_register_interface(dbus, IWD_AGENT_MANAGER_INTERFACE,
|
||||
@ -628,7 +631,7 @@ bool agent_init(struct l_dbus *dbus)
|
||||
NULL, false)) {
|
||||
l_info("Unable to register %s interface",
|
||||
IWD_AGENT_MANAGER_INTERFACE);
|
||||
return false;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (!l_dbus_object_add_interface(dbus, IWD_AGENT_MANAGER_PATH,
|
||||
@ -637,24 +640,26 @@ bool agent_init(struct l_dbus *dbus)
|
||||
l_info("Unable to register the agent manager object on '%s'",
|
||||
IWD_AGENT_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
|
||||
return false;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool agent_exit(struct l_dbus *dbus)
|
||||
static void agent_exit(void)
|
||||
{
|
||||
struct l_dbus *dbus = dbus_get_bus();
|
||||
|
||||
l_dbus_unregister_object(dbus, IWD_AGENT_MANAGER_PATH);
|
||||
l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE);
|
||||
|
||||
l_queue_destroy(agents, agent_free);
|
||||
agents = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void agent_shutdown(void)
|
||||
{
|
||||
l_queue_foreach_remove(agents, release_agent, NULL);
|
||||
}
|
||||
|
||||
IWD_MODULE(agent, agent_init, agent_exit);
|
||||
|
@ -37,8 +37,6 @@ typedef void (*agent_request_user_name_passwd_func_t) (enum agent_result result,
|
||||
void *user_data);
|
||||
typedef void (*agent_request_destroy_func_t)(void *user_data);
|
||||
|
||||
bool agent_init(struct l_dbus *dbus);
|
||||
bool agent_exit(struct l_dbus *dbus);
|
||||
void agent_shutdown(void);
|
||||
|
||||
unsigned int agent_request_passphrase(const char *path,
|
||||
|
@ -210,12 +210,11 @@ struct l_dbus *dbus_get_bus(void)
|
||||
bool dbus_init(struct l_dbus *dbus)
|
||||
{
|
||||
g_dbus = dbus;
|
||||
return agent_init(dbus);
|
||||
return true;
|
||||
}
|
||||
|
||||
void dbus_exit(void)
|
||||
{
|
||||
agent_exit(g_dbus);
|
||||
g_dbus = NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user