mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
client: implement agent-manager API
This commit is contained in:
parent
322f32295d
commit
d1a00d9b34
@ -126,7 +126,7 @@ bin_PROGRAMS += client/iwctl
|
||||
|
||||
client_iwctl_SOURCES = client/main.c \
|
||||
client/adapter.c \
|
||||
client/agent-manager.c \
|
||||
client/agent-manager.h client/agent-manager.c \
|
||||
client/command.h client/command.c \
|
||||
client/dbus-proxy.h client/dbus-proxy.c \
|
||||
client/device.h client/device.c \
|
||||
@ -288,6 +288,7 @@ unit_test_eap_mschapv2_LDADD = ell/libell-internal.la
|
||||
unit_test_client_SOURCES = unit/test-client.c \
|
||||
readline/readline.h readline/history.h \
|
||||
client/adapter.c \
|
||||
client/agent-manager.h client/agent-manager.c \
|
||||
client/command.h client/command.c \
|
||||
client/dbus-proxy.h client/dbus-proxy.c \
|
||||
client/display.h client/display.c \
|
||||
|
@ -27,10 +27,59 @@
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "dbus-proxy.h"
|
||||
#include "display.h"
|
||||
#include "agent-manager.h"
|
||||
|
||||
#define IWD_AGENT_MANAGER_INTERFACE "net.connman.iwd.AgentManager"
|
||||
#define IWD_AGENT_MANAGER_PATH "/"
|
||||
|
||||
static void check_errors_method_callback(struct l_dbus_message *message,
|
||||
void *user_data)
|
||||
{
|
||||
dbus_message_has_error(message);
|
||||
}
|
||||
|
||||
bool agent_manager_register_agent(void)
|
||||
{
|
||||
const char *path;
|
||||
const struct proxy_interface *proxy =
|
||||
proxy_interface_find(IWD_AGENT_MANAGER_INTERFACE,
|
||||
IWD_AGENT_MANAGER_PATH);
|
||||
|
||||
if (!proxy)
|
||||
return false;
|
||||
|
||||
path = proxy_interface_get_data(proxy);
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
proxy_interface_method_call(proxy, "RegisterAgent", "o",
|
||||
check_errors_method_callback, path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool agent_manager_unregister_agent(void)
|
||||
{
|
||||
const char *path;
|
||||
const struct proxy_interface *proxy =
|
||||
proxy_interface_find(IWD_AGENT_MANAGER_INTERFACE,
|
||||
IWD_AGENT_MANAGER_PATH);
|
||||
|
||||
if (!proxy)
|
||||
return false;
|
||||
|
||||
path = proxy_interface_get_data(proxy);
|
||||
if (!path)
|
||||
return false;
|
||||
|
||||
proxy_interface_method_call(proxy, "UnregisterAgent", "o",
|
||||
check_errors_method_callback, path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static struct proxy_interface_type agent_manager_interface_type = {
|
||||
.interface = "net.connman.iwd.AgentManager",
|
||||
.interface = IWD_AGENT_MANAGER_INTERFACE,
|
||||
};
|
||||
|
||||
static int agent_manager_interface_init(void)
|
||||
|
24
client/agent-manager.h
Normal file
24
client/agent-manager.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
*
|
||||
* Wireless daemon for Linux
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
bool agent_manager_register_agent(void);
|
||||
bool agent_manager_unregister_agent(void);
|
@ -27,6 +27,7 @@
|
||||
#include <stdio.h>
|
||||
#include <ell/ell.h>
|
||||
|
||||
#include "agent-manager.h"
|
||||
#include "dbus-proxy.h"
|
||||
#include "display.h"
|
||||
|
||||
@ -578,6 +579,12 @@ static void get_managed_objects_callback(struct l_dbus_message *message,
|
||||
while (l_dbus_message_iter_next_entry(&objects, &path, &object))
|
||||
proxy_interface_create(path, &object);
|
||||
|
||||
if (!agent_manager_register_agent()) {
|
||||
l_main_quit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
display_enable_cmd_prompt();
|
||||
}
|
||||
|
||||
@ -670,6 +677,8 @@ bool dbus_proxy_exit(void)
|
||||
{
|
||||
struct interface_type_desc *desc;
|
||||
|
||||
agent_manager_unregister_agent();
|
||||
|
||||
for (desc = __start___interface; desc < __stop___interface; desc++) {
|
||||
if (!desc->exit)
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user