From 85a1678147d0b6d91b8c82d30e7ce3f8c40e4e5a Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Thu, 3 May 2018 13:57:51 -0700 Subject: [PATCH] client: introduce agent --- Makefile.am | 2 ++ client/agent.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ client/agent.h | 26 +++++++++++++++ client/dbus-proxy.c | 5 +++ client/dbus-proxy.h | 2 ++ 5 files changed, 115 insertions(+) create mode 100644 client/agent.c create mode 100644 client/agent.h diff --git a/Makefile.am b/Makefile.am index 63df381a..d1109951 100644 --- a/Makefile.am +++ b/Makefile.am @@ -126,6 +126,7 @@ bin_PROGRAMS += client/iwctl client_iwctl_SOURCES = client/main.c \ client/adapter.c \ + client/agent.h client/agent.c \ client/agent-manager.h client/agent-manager.c \ client/command.h client/command.c \ client/dbus-proxy.h client/dbus-proxy.c \ @@ -288,6 +289,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.h client/agent.c \ client/agent-manager.h client/agent-manager.c \ client/command.h client/command.c \ client/dbus-proxy.h client/dbus-proxy.c \ diff --git a/client/agent.c b/client/agent.c new file mode 100644 index 00000000..378d0f64 --- /dev/null +++ b/client/agent.c @@ -0,0 +1,80 @@ +/* + * + * 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 + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "agent.h" +#include "dbus-proxy.h" +#include "display.h" + +#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent" + +static struct l_dbus_message *pending_message; + +static void setup_agent_interface(struct l_dbus_interface *interface) +{ +} + +bool agent_prompt(const char *prompt) +{ + return false; +} + +bool agent_init(const char *path) +{ + struct l_dbus *dbus = dbus_get_bus(); + + if (!l_dbus_register_interface(dbus, IWD_AGENT_INTERFACE, + setup_agent_interface, NULL, false)) { + l_info("Unable to register %s interface", IWD_AGENT_INTERFACE); + + return false; + } + + if (!l_dbus_object_add_interface(dbus, path, IWD_AGENT_INTERFACE, + NULL)) { + l_info("Unable to register the agent manager object on '%s'", + path); + l_dbus_unregister_interface(dbus, IWD_AGENT_INTERFACE); + + return false; + } + + return true; +} + +bool agent_exit(const char *path) +{ + struct l_dbus *dbus = dbus_get_bus(); + + if (pending_message) + l_dbus_message_unref(pending_message); + + l_dbus_unregister_object(dbus, path); + l_dbus_unregister_interface(dbus, IWD_AGENT_INTERFACE); + + return true; +} diff --git a/client/agent.h b/client/agent.h new file mode 100644 index 00000000..c7c337fb --- /dev/null +++ b/client/agent.h @@ -0,0 +1,26 @@ +/* + * + * 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_prompt(const char *prompt); + +bool agent_init(const char *path); +bool agent_exit(const char *path); diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c index 448a9a3f..65fe8d9f 100644 --- a/client/dbus-proxy.c +++ b/client/dbus-proxy.c @@ -639,6 +639,11 @@ void proxy_interface_type_unregister( l_queue_remove(proxy_interface_types, (void *) interface_type); } +struct l_dbus *dbus_get_bus(void) +{ + return dbus; +} + extern struct interface_type_desc __start___interface[]; extern struct interface_type_desc __stop___interface[]; diff --git a/client/dbus-proxy.h b/client/dbus-proxy.h index eda7b130..8da079bb 100644 --- a/client/dbus-proxy.h +++ b/client/dbus-proxy.h @@ -91,6 +91,8 @@ void proxy_interface_type_register( void proxy_interface_type_unregister( const struct proxy_interface_type *interface_type); +struct l_dbus *dbus_get_bus(void); + struct interface_type_desc { const char *interface; int (*init)(void);