* [PATCH 2/4] client: Add start/stop ops to agent manager proxy
2019-12-05 21:52 [PATCH 1/4] client: Extend client proxy object's API Tim Kourt
@ 2019-12-05 21:52 ` Tim Kourt
2019-12-05 21:52 ` [PATCH 3/4] client: Remove explicit agent registartion from framework Tim Kourt
2019-12-05 21:52 ` [PATCH 4/4] client: Use full include path for local includes Tim Kourt
2 siblings, 0 replies; 4+ messages in thread
From: Tim Kourt @ 2019-12-05 21:52 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 2265 bytes --]
This guarantees that the agent gets registered only when the agent
manager interface is available on dbus.
---
client/agent-manager.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 7 deletions(-)
diff --git a/client/agent-manager.c b/client/agent-manager.c
index b7d4271b..fb371ea2 100644
--- a/client/agent-manager.c
+++ b/client/agent-manager.c
@@ -30,6 +30,7 @@
#include "agent.h"
#include "dbus-proxy.h"
#include "agent-manager.h"
+#include "command.h"
#define IWD_AGENT_MANAGER_PATH "/net/connman/iwd"
@@ -39,6 +40,46 @@ static void check_errors_method_callback(struct l_dbus_message *message,
dbus_message_has_error(message);
}
+static bool agent_manager_start(const struct proxy_interface *proxy)
+{
+ const char *path;
+
+ if (command_needs_no_agent())
+ return true;
+
+ path = proxy_interface_get_data(proxy);
+ if (!path)
+ return false;
+
+ if (!agent_init(path))
+ return false;
+
+ proxy_interface_method_call(proxy, "RegisterAgent", "o",
+ check_errors_method_callback, path);
+
+ return true;
+}
+
+static void agent_manager_stop(const struct proxy_interface *proxy)
+{
+ const char *path;
+
+ if (command_needs_no_agent())
+ return;
+
+ if (!proxy)
+ return;
+
+ path = proxy_interface_get_data(proxy);
+ if (!path)
+ return;
+
+ proxy_interface_method_call(proxy, "UnregisterAgent", "o",
+ check_errors_method_callback, path);
+
+ agent_exit(path);
+}
+
bool agent_manager_register_agent(void)
{
const char *path;
@@ -81,25 +122,21 @@ bool agent_manager_unregister_agent(void)
static void *agent_manager_create(void)
{
- char *path = l_strdup_printf("/agent/%i", getpid());
-
- agent_init(path);
-
- return path;
+ return l_strdup_printf("/agent/%i", getpid());
}
static void agent_manager_destroy(void *data)
{
char *path = data;
- agent_exit(path);
-
l_free(path);
}
static const struct proxy_interface_type_ops agent_manager_ops = {
.create = agent_manager_create,
.destroy = agent_manager_destroy,
+ .start = agent_manager_start,
+ .stop = agent_manager_stop,
};
static struct proxy_interface_type agent_manager_interface_type = {
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 3/4] client: Remove explicit agent registartion from framework
2019-12-05 21:52 [PATCH 1/4] client: Extend client proxy object's API Tim Kourt
2019-12-05 21:52 ` [PATCH 2/4] client: Add start/stop ops to agent manager proxy Tim Kourt
@ 2019-12-05 21:52 ` Tim Kourt
2019-12-05 21:52 ` [PATCH 4/4] client: Use full include path for local includes Tim Kourt
2 siblings, 0 replies; 4+ messages in thread
From: Tim Kourt @ 2019-12-05 21:52 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 4956 bytes --]
This removes the no longer needed APIs from agent-manager.
---
Makefile.am | 4 ++--
client/agent-manager.c | 41 -----------------------------------------
client/agent-manager.h | 24 ------------------------
client/dbus-proxy.c | 19 -------------------
4 files changed, 2 insertions(+), 86 deletions(-)
delete mode 100644 client/agent-manager.h
diff --git a/Makefile.am b/Makefile.am
index 1d572db5..7a6faadd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -267,7 +267,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/agent-manager.c \
client/ad-hoc.c \
client/ap.c \
client/command.h client/command.c \
@@ -486,7 +486,7 @@ if CLIENT
unit_test_client_SOURCES = unit/test-client.c \
client/adapter.c \
client/agent.h client/agent.c \
- client/agent-manager.h client/agent-manager.c \
+ client/agent-manager.c \
client/command.h client/command.c \
client/dbus-proxy.h client/dbus-proxy.c \
client/display.h client/display.c \
diff --git a/client/agent-manager.c b/client/agent-manager.c
index fb371ea2..98a78436 100644
--- a/client/agent-manager.c
+++ b/client/agent-manager.c
@@ -29,7 +29,6 @@
#include "agent.h"
#include "dbus-proxy.h"
-#include "agent-manager.h"
#include "command.h"
#define IWD_AGENT_MANAGER_PATH "/net/connman/iwd"
@@ -80,46 +79,6 @@ static void agent_manager_stop(const struct proxy_interface *proxy)
agent_exit(path);
}
-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 void *agent_manager_create(void)
{
return l_strdup_printf("/agent/%i", getpid());
diff --git a/client/agent-manager.h b/client/agent-manager.h
deleted file mode 100644
index c0433f53..00000000
--- a/client/agent-manager.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- *
- * Wireless daemon for Linux
- *
- * Copyright (C) 2017-2019 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);
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
index 70b63686..a8cfca55 100644
--- a/client/dbus-proxy.c
+++ b/client/dbus-proxy.c
@@ -27,7 +27,6 @@
#include <stdio.h>
#include <ell/ell.h>
-#include "agent-manager.h"
#include "dbus-proxy.h"
#include "display.h"
#include "command.h"
@@ -732,21 +731,6 @@ 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 (command_needs_no_agent())
- goto no_agent;
-
- if (!agent_manager_register_agent()) {
- display_error("Failed to register Agent.\n");
-
- if (!command_is_interactive_mode())
- command_set_exit_status(EXIT_FAILURE);
-
- l_main_quit();
-
- return;
- }
-
-no_agent:
if (!command_is_interactive_mode()) {
command_noninteractive_trigger();
@@ -867,9 +851,6 @@ bool dbus_proxy_exit(void)
{
struct interface_type_desc *desc;
- if (!command_needs_no_agent())
- agent_manager_unregister_agent();
-
for (desc = __start___interface; desc < __stop___interface; desc++) {
if (!desc->exit)
continue;
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 4/4] client: Use full include path for local includes
2019-12-05 21:52 [PATCH 1/4] client: Extend client proxy object's API Tim Kourt
2019-12-05 21:52 ` [PATCH 2/4] client: Add start/stop ops to agent manager proxy Tim Kourt
2019-12-05 21:52 ` [PATCH 3/4] client: Remove explicit agent registartion from framework Tim Kourt
@ 2019-12-05 21:52 ` Tim Kourt
2 siblings, 0 replies; 4+ messages in thread
From: Tim Kourt @ 2019-12-05 21:52 UTC (permalink / raw)
To: iwd
[-- Attachment #1: Type: text/plain, Size: 7445 bytes --]
---
client/ad-hoc.c | 8 ++++----
client/adapter.c | 8 ++++----
client/agent-manager.c | 6 +++---
client/agent.c | 8 ++++----
client/ap.c | 8 ++++----
client/command.c | 4 ++--
client/dbus-proxy.c | 8 ++++----
client/device.c | 12 ++++++------
client/display.c | 6 +++---
client/known-networks.c | 10 +++++-----
client/main.c | 6 +++---
client/network.c | 6 +++---
client/properties.c | 2 +-
client/station.c | 10 +++++-----
client/wsc.c | 8 ++++----
15 files changed, 55 insertions(+), 55 deletions(-)
diff --git a/client/ad-hoc.c b/client/ad-hoc.c
index 9fba9c96..41d5e2aa 100644
--- a/client/ad-hoc.c
+++ b/client/ad-hoc.c
@@ -26,10 +26,10 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "device.h"
-#include "display.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/device.h"
+#include "client/display.h"
struct ad_hoc {
bool started;
diff --git a/client/adapter.c b/client/adapter.c
index e815a39b..6a0d3455 100644
--- a/client/adapter.c
+++ b/client/adapter.c
@@ -26,10 +26,10 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "display.h"
-#include "properties.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/properties.h"
struct adapter {
bool powered;
diff --git a/client/agent-manager.c b/client/agent-manager.c
index 98a78436..91cde8c4 100644
--- a/client/agent-manager.c
+++ b/client/agent-manager.c
@@ -27,9 +27,9 @@
#include <ell/ell.h>
#include <unistd.h>
-#include "agent.h"
-#include "dbus-proxy.h"
-#include "command.h"
+#include "client/agent.h"
+#include "client/dbus-proxy.h"
+#include "client/command.h"
#define IWD_AGENT_MANAGER_PATH "/net/connman/iwd"
diff --git a/client/agent.c b/client/agent.c
index 16bc3c4f..b804b50d 100644
--- a/client/agent.c
+++ b/client/agent.c
@@ -26,10 +26,10 @@
#include <ell/ell.h>
-#include "agent.h"
-#include "dbus-proxy.h"
-#include "display.h"
-#include "command.h"
+#include "client/agent.h"
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/command.h"
#define IWD_AGENT_INTERFACE "net.connman.iwd.Agent"
diff --git a/client/ap.c b/client/ap.c
index bf55d07f..a6a2681b 100644
--- a/client/ap.c
+++ b/client/ap.c
@@ -26,10 +26,10 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "device.h"
-#include "display.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/device.h"
+#include "client/display.h"
struct ap {
bool started;
diff --git a/client/command.c b/client/command.c
index 5441188a..74f11c4a 100644
--- a/client/command.c
+++ b/client/command.c
@@ -31,8 +31,8 @@
#include <ell/ell.h>
#include <readline/readline.h>
-#include "command.h"
-#include "display.h"
+#include "client/command.h"
+#include "client/display.h"
static struct l_queue *command_families;
static struct l_queue *command_options;
diff --git a/client/dbus-proxy.c b/client/dbus-proxy.c
index a8cfca55..313cd5a6 100644
--- a/client/dbus-proxy.c
+++ b/client/dbus-proxy.c
@@ -27,10 +27,10 @@
#include <stdio.h>
#include <ell/ell.h>
-#include "dbus-proxy.h"
-#include "display.h"
-#include "command.h"
-#include "properties.h"
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/command.h"
+#include "client/properties.h"
#define IWD_SERVICE "net.connman.iwd"
#define IWD_ROOT_PATH "/"
diff --git a/client/device.c b/client/device.c
index ef109c84..5b971883 100644
--- a/client/device.c
+++ b/client/device.c
@@ -26,12 +26,12 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "device.h"
-#include "display.h"
-#include "network.h"
-#include "properties.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/device.h"
+#include "client/display.h"
+#include "client/network.h"
+#include "client/properties.h"
struct device {
bool powered;
diff --git a/client/display.c b/client/display.c
index 10c87b2a..349eb503 100644
--- a/client/display.c
+++ b/client/display.c
@@ -32,9 +32,9 @@
#include <readline/readline.h>
#include <ell/ell.h>
-#include "agent.h"
-#include "command.h"
-#include "display.h"
+#include "client/agent.h"
+#include "client/command.h"
+#include "client/display.h"
#define IWD_PROMPT COLOR_GREEN "[iwd]" COLOR_OFF "# "
#define LINE_LEN 81
diff --git a/client/known-networks.c b/client/known-networks.c
index 7cfc2ecf..45f60af2 100644
--- a/client/known-networks.c
+++ b/client/known-networks.c
@@ -29,11 +29,11 @@
#include <time.h>
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "display.h"
-#include "properties.h"
-#include "network.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/properties.h"
+#include "client/network.h"
struct known_network {
char *identity;
diff --git a/client/main.c b/client/main.c
index 54d4cb31..8ca45a15 100644
--- a/client/main.c
+++ b/client/main.c
@@ -28,9 +28,9 @@
#include <signal.h>
#include <ell/ell.h>
-#include "command.h"
-#include "display.h"
-#include "dbus-proxy.h"
+#include "client/command.h"
+#include "client/display.h"
+#include "client/dbus-proxy.h"
static void signal_handler(uint32_t signo, void *user_data)
{
diff --git a/client/network.c b/client/network.c
index fdeeef67..6b79bcd1 100644
--- a/client/network.c
+++ b/client/network.c
@@ -26,9 +26,9 @@
#include <ell/ell.h>
-#include "dbus-proxy.h"
-#include "display.h"
-#include "network.h"
+#include "client/dbus-proxy.h"
+#include "client/display.h"
+#include "client/network.h"
struct network {
bool connected;
diff --git a/client/properties.c b/client/properties.c
index 8838f4f0..dadf660d 100644
--- a/client/properties.c
+++ b/client/properties.c
@@ -26,7 +26,7 @@
#include <ell/ell.h>
-#include "properties.h"
+#include "client/properties.h"
const char *properties_on_off_opts[3] = { "on", "off", NULL };
const char *properties_yes_no_opts[3] = { "yes", "no", NULL };
diff --git a/client/station.c b/client/station.c
index dbcfa88f..b6b59239 100644
--- a/client/station.c
+++ b/client/station.c
@@ -26,11 +26,11 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "device.h"
-#include "network.h"
-#include "display.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/device.h"
+#include "client/network.h"
+#include "client/display.h"
struct station {
bool scanning;
diff --git a/client/wsc.c b/client/wsc.c
index ffbb54aa..39950453 100644
--- a/client/wsc.c
+++ b/client/wsc.c
@@ -26,10 +26,10 @@
#include <ell/ell.h>
-#include "command.h"
-#include "dbus-proxy.h"
-#include "device.h"
-#include "display.h"
+#include "client/command.h"
+#include "client/dbus-proxy.h"
+#include "client/device.h"
+#include "client/display.h"
static struct proxy_interface_type wsc_interface_type = {
.interface = IWD_WSC_INTERFACE,
--
2.13.6
^ permalink raw reply related [flat|nested] 4+ messages in thread